mirror of
https://github.com/gone-io/gone.git
synced 2025-01-23 01:00:23 +08:00
feat: test for goner/gorm
This commit is contained in:
parent
d31b84c6d4
commit
a8b7acc9ce
2
.github/workflows/go.yml
vendored
2
.github/workflows/go.yml
vendored
@ -19,6 +19,8 @@ jobs:
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: 'stable'
|
||||
- name: Install SQLite
|
||||
run: sudo apt-get update && sudo apt-get install -y sqlite3 libsqlite3-dev
|
||||
- name: Gather dependencies
|
||||
run: go mod download
|
||||
- name: Run coverage
|
||||
|
@ -12,15 +12,15 @@ type dial struct {
|
||||
|
||||
driverName string `gone:"config,gorm.clickhouse.driver-name"`
|
||||
dsn string `gone:"config,gorm.clickhouse.dsn"`
|
||||
disableDatetimePrecision bool `gone:"gorm.clickhouse.disable-datetime-precision,default=false"`
|
||||
dontSupportRenameColumn bool `gone:"gorm.clickhouse.dont-support-rename-column,default=false"`
|
||||
dontSupportColumnPrecision bool `gone:"gorm.clickhouse.dont-support-column-precision,default=false"`
|
||||
dontSupportEmptyDefaultValue bool `gone:"gorm.clickhouse.dont-support-empty-default-value,default=false"`
|
||||
skipInitializeWithVersion bool `gone:"gorm.clickhouse.skip-initialize-with-version,default=false"`
|
||||
defaultGranularity int `gone:"gorm.clickhouse.default-granularity,default="`
|
||||
defaultCompression string `gone:"gorm.clickhouse.default-compression,default="`
|
||||
defaultIndexType string `gone:"gorm.clickhouse.default-indexType,default="`
|
||||
defaultTableEngineOpts string `gone:"gorm.clickhouse.default-table-engine-opts,default="`
|
||||
disableDatetimePrecision bool `gone:"config,gorm.clickhouse.disable-datetime-precision,default=false"`
|
||||
dontSupportRenameColumn bool `gone:"config,gorm.clickhouse.dont-support-rename-column,default=false"`
|
||||
dontSupportColumnPrecision bool `gone:"config,gorm.clickhouse.dont-support-column-precision,default=false"`
|
||||
dontSupportEmptyDefaultValue bool `gone:"config,gorm.clickhouse.dont-support-empty-default-value,default=false"`
|
||||
skipInitializeWithVersion bool `gone:"config,gorm.clickhouse.skip-initialize-with-version,default=false"`
|
||||
defaultGranularity int `gone:"config,gorm.clickhouse.default-granularity,default="`
|
||||
defaultCompression string `gone:"config,gorm.clickhouse.default-compression,default="`
|
||||
defaultIndexType string `gone:"config,gorm.clickhouse.default-indexType,default="`
|
||||
defaultTableEngineOpts string `gone:"config,gorm.clickhouse.default-table-engine-opts,default="`
|
||||
}
|
||||
|
||||
func (d *dial) Apply(*gorm.Config) error {
|
||||
|
24
goner/gorm/clickhouse/conn_test.go
Normal file
24
goner/gorm/clickhouse/conn_test.go
Normal file
@ -0,0 +1,24 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"github.com/gone-io/gone"
|
||||
"github.com/gone-io/gone/goner/config"
|
||||
goneGorm "github.com/gone-io/gone/goner/gorm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gorm.io/gorm"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPriest(t *testing.T) {
|
||||
gone.RunTest(func(in struct {
|
||||
dial gorm.Dialector `gone:"*"`
|
||||
}) {
|
||||
assert.NotNil(t, in.dial)
|
||||
err := in.dial.(goneGorm.Applier).Apply(nil)
|
||||
assert.Nil(t, err)
|
||||
|
||||
}, func(cemetery gone.Cemetery) error {
|
||||
_ = config.Priest(cemetery)
|
||||
return Priest(cemetery)
|
||||
})
|
||||
}
|
24
goner/gorm/mysql/conn_test.go
Normal file
24
goner/gorm/mysql/conn_test.go
Normal file
@ -0,0 +1,24 @@
|
||||
package mysql
|
||||
|
||||
import (
|
||||
"github.com/gone-io/gone"
|
||||
"github.com/gone-io/gone/goner/config"
|
||||
goneGorm "github.com/gone-io/gone/goner/gorm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gorm.io/gorm"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPriest(t *testing.T) {
|
||||
gone.RunTest(func(in struct {
|
||||
dial gorm.Dialector `gone:"*"`
|
||||
}) {
|
||||
assert.NotNil(t, in.dial)
|
||||
err := in.dial.(goneGorm.Applier).Apply(nil)
|
||||
assert.Nil(t, err)
|
||||
|
||||
}, func(cemetery gone.Cemetery) error {
|
||||
_ = config.Priest(cemetery)
|
||||
return Priest(cemetery)
|
||||
})
|
||||
}
|
24
goner/gorm/postgres/conn_test.go
Normal file
24
goner/gorm/postgres/conn_test.go
Normal file
@ -0,0 +1,24 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"github.com/gone-io/gone"
|
||||
"github.com/gone-io/gone/goner/config"
|
||||
goneGorm "github.com/gone-io/gone/goner/gorm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gorm.io/gorm"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPriest(t *testing.T) {
|
||||
gone.RunTest(func(in struct {
|
||||
dial gorm.Dialector `gone:"*"`
|
||||
}) {
|
||||
assert.NotNil(t, in.dial)
|
||||
err := in.dial.(goneGorm.Applier).Apply(nil)
|
||||
assert.Nil(t, err)
|
||||
|
||||
}, func(cemetery gone.Cemetery) error {
|
||||
_ = config.Priest(cemetery)
|
||||
return Priest(cemetery)
|
||||
})
|
||||
}
|
@ -7,6 +7,10 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Applier interface {
|
||||
Apply(*gorm.Config) error
|
||||
}
|
||||
|
||||
func ProviderPriest(cemetery gone.Cemetery) error {
|
||||
var gInstance *gorm.DB
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mysql
|
||||
package sqlite
|
||||
|
||||
import (
|
||||
"github.com/gone-io/gone"
|
||||
|
24
goner/gorm/sqlite/conn_test.go
Normal file
24
goner/gorm/sqlite/conn_test.go
Normal file
@ -0,0 +1,24 @@
|
||||
package sqlite
|
||||
|
||||
import (
|
||||
"github.com/gone-io/gone"
|
||||
"github.com/gone-io/gone/goner/config"
|
||||
goneGorm "github.com/gone-io/gone/goner/gorm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gorm.io/gorm"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPriest(t *testing.T) {
|
||||
gone.RunTest(func(in struct {
|
||||
dial gorm.Dialector `gone:"*"`
|
||||
}) {
|
||||
assert.NotNil(t, in.dial)
|
||||
err := in.dial.(goneGorm.Applier).Apply(nil)
|
||||
assert.Nil(t, err)
|
||||
|
||||
}, func(cemetery gone.Cemetery) error {
|
||||
_ = config.Priest(cemetery)
|
||||
return Priest(cemetery)
|
||||
})
|
||||
}
|
1
goner/gorm/sqlite/testdata/config/default_test.properties
vendored
Normal file
1
goner/gorm/sqlite/testdata/config/default_test.properties
vendored
Normal file
@ -0,0 +1 @@
|
||||
gorm.sqlite.dsn=./testdata/test.db
|
@ -1,4 +1,4 @@
|
||||
package mysql
|
||||
package sqlserver
|
||||
|
||||
import (
|
||||
"github.com/gone-io/gone"
|
||||
|
24
goner/gorm/sqlserver/conn_test.go
Normal file
24
goner/gorm/sqlserver/conn_test.go
Normal file
@ -0,0 +1,24 @@
|
||||
package sqlserver
|
||||
|
||||
import (
|
||||
"github.com/gone-io/gone"
|
||||
"github.com/gone-io/gone/goner/config"
|
||||
goneGorm "github.com/gone-io/gone/goner/gorm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gorm.io/gorm"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPriest(t *testing.T) {
|
||||
gone.RunTest(func(in struct {
|
||||
dial gorm.Dialector `gone:"*"`
|
||||
}) {
|
||||
assert.NotNil(t, in.dial)
|
||||
err := in.dial.(goneGorm.Applier).Apply(nil)
|
||||
assert.Nil(t, err)
|
||||
|
||||
}, func(cemetery gone.Cemetery) error {
|
||||
_ = config.Priest(cemetery)
|
||||
return Priest(cemetery)
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user