1 Star 0 Fork 15

skymysky / gosql

forked from fifsky / gosql 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
connection_test.go 565 Bytes
一键复制 编辑 原始数据 按行查看 历史
fifsky 提交于 2018-07-14 14:43 . test include mysql driver
package gosql
import (
"os"
"testing"
_ "github.com/go-sql-driver/mysql"
)
func TestMain(m *testing.M) {
configs := make(map[string]*Config)
dsn := os.Getenv("MYSQL_TEST_DSN")
if dsn == "" {
dsn = "root:123456@tcp(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Asia%2FShanghai"
}
configs["default"] = &Config{
Enable: true,
Driver: "mysql",
Dsn: dsn,
ShowSql: true,
}
Connect(configs)
m.Run()
}
func TestConnect(t *testing.T) {
db := DB()
if db.DriverName() != "mysql" {
t.Fatalf("sqlx database connection error")
}
}
Go
1
https://gitee.com/skymysky/gosql.git
git@gitee.com:skymysky/gosql.git
skymysky
gosql
gosql
master

搜索帮助