1 Star 0 Fork 15

unsafe-rust/gosql

forked from fifsky/gosql 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
connection_test.go 836 Bytes
一键复制 编辑 原始数据 按行查看 历史
fifsky 提交于 2019-10-16 16:19 . support postgres sql quotes,fix #15
package gosql
import (
"os"
"testing"
_ "github.com/go-sql-driver/mysql"
)
func TestMain(m *testing.M) {
configs := make(map[string]*Config)
dsn1 := os.Getenv("MYSQL_TEST_DSN1")
if dsn1 == "" {
dsn1 = "root:123456@tcp(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Asia%2FShanghai"
}
dsn2 := os.Getenv("MYSQL_TEST_DSN2")
if dsn2 == "" {
dsn2 = "root:123456@tcp(127.0.0.1:3306)/test2?charset=utf8&parseTime=True&loc=Asia%2FShanghai"
}
configs["default"] = &Config{
Enable: true,
Driver: "mysql",
Dsn: dsn1,
ShowSql: true,
}
configs["db2"] = &Config{
Enable: true,
Driver: "mysql",
Dsn: dsn2,
ShowSql: true,
}
_ = Connect(configs)
m.Run()
}
func TestConnect(t *testing.T) {
db := Sqlx()
if db.DriverName() != "mysql" {
t.Fatalf("sqlx database connection error")
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/unsafe-rust/gosql.git
git@gitee.com:unsafe-rust/gosql.git
unsafe-rust
gosql
gosql
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385