mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
feature/v2.2.0 (#2154)
This commit is contained in:
@ -59,7 +59,7 @@ func Database(name ...string) gdb.DB {
|
||||
if fileConfig, ok := Config().GetAdapter().(*gcfg.AdapterFile); ok {
|
||||
if _, err = fileConfig.GetFilePath(); err != nil {
|
||||
panic(gerror.WrapCode(gcode.CodeMissingConfiguration, err,
|
||||
`configuration not found, did you miss the configuration file or the misspell the configuration file name`,
|
||||
`configuration not found, did you miss the configuration file or misspell the configuration file name`,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,15 +41,16 @@ func Test_Database(t *testing.T) {
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
||||
// fmt.Println("gins Test_Database", Config().Get("test"))
|
||||
|
||||
dbDefault := gins.Database()
|
||||
dbTest := gins.Database("test")
|
||||
var (
|
||||
db = gins.Database()
|
||||
dbDefault = gins.Database("default")
|
||||
)
|
||||
t.AssertNE(db, nil)
|
||||
t.AssertNE(dbDefault, nil)
|
||||
t.AssertNE(dbTest, nil)
|
||||
|
||||
t.Assert(db.PingMaster(), nil)
|
||||
t.Assert(db.PingSlave(), nil)
|
||||
t.Assert(dbDefault.PingMaster(), nil)
|
||||
t.Assert(dbDefault.PingSlave(), nil)
|
||||
t.Assert(dbTest.PingMaster(), nil)
|
||||
t.Assert(dbTest.PingSlave(), nil)
|
||||
})
|
||||
}
|
||||
|
||||
4
frame/gins/testdata/database/config.toml
vendored
4
frame/gins/testdata/database/config.toml
vendored
@ -9,7 +9,7 @@ test = "v=2"
|
||||
user = "root"
|
||||
pass = "12345678"
|
||||
name = "test"
|
||||
type = "test"
|
||||
type = "default"
|
||||
role = "master"
|
||||
weight = "1"
|
||||
charset = "utf8"
|
||||
@ -19,7 +19,7 @@ test = "v=2"
|
||||
user = "root"
|
||||
pass = "12345678"
|
||||
name = "test"
|
||||
type = "test"
|
||||
type = "default"
|
||||
role = "master"
|
||||
weight = "1"
|
||||
charset = "utf8"
|
||||
|
||||
Reference in New Issue
Block a user