Files
EdgeAPI/internal/db/models/node_ip_address_dao_test.go
GoEdgeLab 5a17ae9d79 v1.4.1
2024-07-27 14:15:25 +08:00

66 lines
1.3 KiB
Go

//go:build plus
// +build plus
package models
import (
"testing"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
_ "github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/dbs"
)
func TestNodeIPAddressDAO_FireThresholds(t *testing.T) {
dbs.NotifyReady()
var tx *dbs.Tx
var nodeId int64 = 126
node, err := SharedNodeDAO.FindEnabledNode(tx, nodeId)
if err != nil {
t.Fatal(err)
}
if node == nil {
t.Log("node not found")
return
}
err = SharedNodeIPAddressDAO.FireThresholds(tx, nodeconfigs.NodeRoleNode, nodeId)
if err != nil {
t.Fatal(err)
}
t.Log("ok")
}
func TestNodeIPAddressDAO_LoopTasks(t *testing.T) {
dbs.NotifyReady()
var tx *dbs.Tx
err := SharedNodeIPAddressDAO.loopTask(tx, nodeconfigs.NodeRoleNode)
if err != nil {
t.Fatal(err)
}
t.Log("ok")
}
func TestNodeIPAddressDAO_FindAddressIsHealthy(t *testing.T) {
dbs.NotifyReady()
var tx *dbs.Tx
isHealthy, err := SharedNodeIPAddressDAO.FindAddressIsHealthy(tx, 1)
if err != nil {
t.Fatal(err)
}
t.Log("isHealthy:", isHealthy)
}
func TestNodeIPAddressDAO_UpdateAddressHealthCount(t *testing.T) {
dbs.NotifyReady()
var tx *dbs.Tx
isChanged, err := SharedNodeIPAddressDAO.UpdateAddressHealthCount(tx, 1, true, 3, 3, false)
if err != nil {
t.Fatal(err)
}
t.Log("isChanged:", isChanged)
}