MCPcopy Create free account
hub / github.com/go-dev-frame/sponge / TestGetDB

Function TestGetDB

internal/database/init_test.go:17–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestGetDB(t *testing.T) {
18 err := config.Init(configs.Path("serverNameExample.yml"))
19 if err != nil {
20 panic(err)
21 }
22
23 config.Get().App.EnableTrace = true
24 config.Get().Database.Mysql.EnableLog = true
25
26 time.Sleep(time.Millisecond * 10)
27 err = CloseDB()
28 assert.NoError(t, err)
29
30 utils.SafeRunWithTimeout(time.Second*2, func(cancel context.CancelFunc) {
31 db := GetDB()
32 assert.NotNil(t, db)
33 cancel()
34 })
35}
36
37func TestInitMysqlError(t *testing.T) {
38 err := config.Init(configs.Path("serverNameExample.yml"))

Callers

nothing calls this directly

Calls 6

InitFunction · 0.92
PathFunction · 0.92
GetFunction · 0.92
SafeRunWithTimeoutFunction · 0.92
GetDBFunction · 0.85
CloseDBFunction · 0.70

Tested by

no test coverage detected