db/sqlite3_test.go

37 lines
572 B
Go
Raw Permalink Normal View History

2023-06-15 11:46:17 +08:00
package db
import (
"os"
"testing"
)
var conn *Connection
func TestMain(m *testing.M) {
database := Open(map[string]DBConfig{
"sqlite3": {
Driver: "sqlite3",
File: ":memory:",
},
})
conn = database.Connection("sqlite3")
// 执行测试
code := m.Run()
// 退出测试
os.Exit(code)
}
func TestSqliteQuery(t *testing.T) {
dest := []map[string]any{}
t.Log(conn.Select("select 1 as a, 2 as b", nil, &dest))
t.Log("result: ", dest)
}
func TestSqliteBuilder(t *testing.T) {
t.Log(conn.Query().FromSub("select 1 as a, 2 as b", "tb").ToSql())
}