mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-02 22:10:26 +08:00
105 lines
2.1 KiB
Go
105 lines
2.1 KiB
Go
package setup
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/iwind/TeaGo/dbs"
|
|
)
|
|
|
|
func TestSQLExecutor_Run(t *testing.T) {
|
|
var 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(false)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log("ok")
|
|
}
|
|
|
|
func TestSQLExecutor_checkCluster(t *testing.T) {
|
|
var 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)
|
|
}
|
|
defer func() {
|
|
_ = db.Close()
|
|
}()
|
|
|
|
err = executor.checkCluster(db)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log("ok")
|
|
}
|
|
|
|
func TestSQLExecutor_checkMetricItems(t *testing.T) {
|
|
var 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)
|
|
}
|
|
defer func() {
|
|
_ = db.Close()
|
|
}()
|
|
|
|
err = executor.checkMetricItems(db)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log("ok")
|
|
}
|
|
|
|
func TestSQLExecutor_checkNS(t *testing.T) {
|
|
var 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)
|
|
}
|
|
defer func() {
|
|
_ = db.Close()
|
|
}()
|
|
|
|
err = executor.checkNS(db)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log("ok")
|
|
}
|
|
|
|
func TestSQLExecutor_checkClientAgents(t *testing.T) {
|
|
var executor = NewSQLExecutor(&dbs.DBConfig{
|
|
Driver: "mysql",
|
|
Prefix: "edge",
|
|
Dsn: "root:123456@tcp(127.0.0.1:3306)/db_edge?charset=utf8mb4&multiStatements=true",
|
|
})
|
|
db, err := dbs.NewInstanceFromConfig(executor.dbConfig)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer func() {
|
|
_ = db.Close()
|
|
}()
|
|
|
|
err = executor.checkClientAgents(db)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log("ok")
|
|
}
|