github.com/TeaOSLab/EdgeNode@v1.3.8/internal/utils/agents/manager_test.go (about)

     1  // Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
     2  
     3  package agents_test
     4  
     5  import (
     6  	"github.com/TeaOSLab/EdgeNode/internal/utils/agents"
     7  	"github.com/TeaOSLab/EdgeNode/internal/utils/testutils"
     8  	"github.com/iwind/TeaGo/Tea"
     9  	_ "github.com/iwind/TeaGo/bootstrap"
    10  	"testing"
    11  )
    12  
    13  func TestNewManager(t *testing.T) {
    14  	if !testutils.IsSingleTesting() {
    15  		return
    16  	}
    17  
    18  	var db = agents.NewSQLiteDB(Tea.Root + "/data/agents.db")
    19  	err := db.Init()
    20  	if err != nil {
    21  		t.Fatal(err)
    22  	}
    23  
    24  	var manager = agents.NewManager()
    25  	manager.SetDB(db)
    26  	err = manager.Load()
    27  	if err != nil {
    28  		t.Fatal(err)
    29  	}
    30  
    31  	_, err = manager.Loop()
    32  	if err != nil {
    33  		t.Fatal(err)
    34  	}
    35  
    36  	t.Log(manager.LookupIP("192.168.3.100"))
    37  }