fix tests

This commit is contained in:
Matthew R Kasun
2023-02-14 07:58:54 -05:00
parent 82cac8fa30
commit 65b31c1c04
9 changed files with 73 additions and 59 deletions

View File

@@ -1,16 +1,38 @@
package logic
import (
"context"
"net"
"testing"
"github.com/google/uuid"
"github.com/gravitl/netmaker/database"
"github.com/gravitl/netmaker/logger"
"github.com/gravitl/netmaker/models"
"github.com/matryer/is"
)
func TestMain(m *testing.M) {
database.InitializeDatabase()
defer database.CloseDB()
CreateAdmin(&models.User{
UserName: "admin",
Password: "password",
IsAdmin: true,
Networks: []string{},
Groups: []string{},
})
peerUpdate := make(chan *models.Node)
go ManageZombies(context.Background(), peerUpdate)
go func() {
for update := range peerUpdate {
//do nothing
logger.Log(3, "received node update", update.Action)
}
}()
}
func TestCheckPorts(t *testing.T) {
initialize()
h := models.Host{
ID: uuid.New(),
EndpointIP: net.ParseIP("192.168.1.1"),