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()) }