2019-04-02 14:37:46 +08:00
|
|
|
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
|
|
|
|
|
|
package gdb_test
|
|
|
|
|
|
|
|
import (
|
2019-06-21 22:23:07 +08:00
|
|
|
"testing"
|
|
|
|
|
2019-07-29 21:01:19 +08:00
|
|
|
"github.com/gogf/gf/database/gdb"
|
|
|
|
"github.com/gogf/gf/test/gtest"
|
2019-04-02 14:37:46 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func Test_Instance(t *testing.T) {
|
2020-03-19 22:56:12 +08:00
|
|
|
gtest.C(t, func(t *gtest.T) {
|
2019-06-19 09:06:52 +08:00
|
|
|
_, err := gdb.Instance("none")
|
2020-03-19 22:56:12 +08:00
|
|
|
t.AssertNE(err, nil)
|
2019-04-02 14:37:46 +08:00
|
|
|
|
2019-06-19 09:06:52 +08:00
|
|
|
db, err := gdb.Instance()
|
2020-03-19 22:56:12 +08:00
|
|
|
t.Assert(err, nil)
|
2019-04-02 14:37:46 +08:00
|
|
|
|
2019-06-19 09:06:52 +08:00
|
|
|
err1 := db.PingMaster()
|
|
|
|
err2 := db.PingSlave()
|
2020-03-19 22:56:12 +08:00
|
|
|
t.Assert(err1, nil)
|
|
|
|
t.Assert(err2, nil)
|
2019-06-19 09:06:52 +08:00
|
|
|
})
|
2019-04-02 14:37:46 +08:00
|
|
|
}
|