Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
hwbrzzl committed Dec 18, 2024
1 parent d09e194 commit ee8c73a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion contracts/database/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Config struct {
Database string
Username string
Password string
// Only for Postgres and Sqlserver
// Only for Postgres
Schema string
}

Expand Down
12 changes: 9 additions & 3 deletions database/gorm/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ func (r *MockMysql) WithPrefixAndSingular() {
r.basic()
}

func (r *MockMysql) WithSchema(schema string) {}
func (r *MockMysql) WithSchema(schema string) {
panic("mysql does not support schema")

Check warning on line 345 in database/gorm/test_utils.go

View check run for this annotation

Codecov / codecov/patch

database/gorm/test_utils.go#L344-L345

Added lines #L344 - L345 were not covered by tests
}

func (r *MockMysql) basic() {
r.mockConfig.On("GetBool", "app.debug").Return(true)
Expand Down Expand Up @@ -488,7 +490,9 @@ func (r *MockSqlite) WithPrefixAndSingular() {
r.basic()
}

func (r *MockSqlite) WithSchema(schema string) {}
func (r *MockSqlite) WithSchema(schema string) {
panic("sqlite does not support schema")

Check warning on line 494 in database/gorm/test_utils.go

View check run for this annotation

Codecov / codecov/patch

database/gorm/test_utils.go#L493-L494

Added lines #L493 - L494 were not covered by tests
}

func (r *MockSqlite) basic() {
r.mockConfig.On("GetBool", "app.debug").Return(true)
Expand Down Expand Up @@ -552,7 +556,9 @@ func (r *MockSqlserver) WithPrefixAndSingular() {
r.basic()
}

func (r *MockSqlserver) WithSchema(schema string) {}
func (r *MockSqlserver) WithSchema(schema string) {
panic("sqlserver does not support schema for now")

Check warning on line 560 in database/gorm/test_utils.go

View check run for this annotation

Codecov / codecov/patch

database/gorm/test_utils.go#L559-L560

Added lines #L559 - L560 were not covered by tests
}

func (r *MockSqlserver) basic() {
r.mockConfig.On("GetBool", "app.debug").Return(true)
Expand Down
2 changes: 1 addition & 1 deletion database/migration/default_migrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package migration

import (
"errors"
"github.com/stretchr/testify/require"
"io"
"os"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

contractsdatabase "github.com/goravel/framework/contracts/database"
Expand Down
4 changes: 2 additions & 2 deletions database/schema/schema_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package schema

import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
"time"

"github.com/spf13/cast"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

"github.com/goravel/framework/contracts/database"
Expand Down
1 change: 1 addition & 0 deletions foundation/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ func (s *ApplicationTestSuite) TestMakeOrm() {
mockConfig.EXPECT().GetString("database.connections.postgres.sslmode").Return("disable").Twice()
mockConfig.EXPECT().GetString("database.connections.postgres.timezone").Return("UTC").Twice()
mockConfig.EXPECT().GetString("database.connections.postgres.database").Return(config.Database).Twice()
mockConfig.EXPECT().GetString("database.connections.postgres.schema", "public").Return("public").Twice()
mockConfig.EXPECT().GetBool("app.debug").Return(true).Once()
mockConfig.EXPECT().GetInt("database.pool.max_idle_conns", 10).Return(10).Once()
mockConfig.EXPECT().GetInt("database.pool.max_open_conns", 100).Return(100).Once()
Expand Down

0 comments on commit ee8c73a

Please sign in to comment.