2020-10-13 20:05:13 +08:00
|
|
|
package setup
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/iwind/TeaGo/dbs"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestSQLExecutor_Run(t *testing.T) {
|
|
|
|
|
executor := NewSQLExecutor(&dbs.DBConfig{
|
|
|
|
|
Driver: "mysql",
|
|
|
|
|
Prefix: "edge",
|
|
|
|
|
Dsn: "root:123456@tcp(127.0.0.1:3306)/db_edge_new?charset=utf8mb4&multiStatements=true",
|
|
|
|
|
})
|
|
|
|
|
err := executor.Run()
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
t.Log("ok")
|
|
|
|
|
}
|
2021-07-19 20:38:30 +08:00
|
|
|
|
|
|
|
|
func TestSQLExecutor_checkMetricItems(t *testing.T) {
|
|
|
|
|
executor := NewSQLExecutor(&dbs.DBConfig{
|
|
|
|
|
Driver: "mysql",
|
|
|
|
|
Prefix: "edge",
|
|
|
|
|
Dsn: "root:123456@tcp(127.0.0.1:3306)/db_edge_new?charset=utf8mb4&multiStatements=true",
|
|
|
|
|
})
|
|
|
|
|
db, err := dbs.NewInstanceFromConfig(executor.dbConfig)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = executor.checkMetricItems(db)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
t.Log("ok")
|
|
|
|
|
}
|
2021-08-05 16:08:01 +08:00
|
|
|
|
|
|
|
|
func TestSQLExecutor_checkNS(t *testing.T) {
|
|
|
|
|
executor := NewSQLExecutor(&dbs.DBConfig{
|
|
|
|
|
Driver: "mysql",
|
|
|
|
|
Prefix: "edge",
|
|
|
|
|
Dsn: "root:123456@tcp(127.0.0.1:3306)/db_edge_new?charset=utf8mb4&multiStatements=true",
|
|
|
|
|
})
|
|
|
|
|
db, err := dbs.NewInstanceFromConfig(executor.dbConfig)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = executor.checkNS(db)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
t.Log("ok")
|
|
|
|
|
}
|