github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/pkg/node/manager_test.go (about)

     1  package node
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/Asutorufa/yuhaiin/pkg/protos/node"
     7  	"github.com/Asutorufa/yuhaiin/pkg/protos/node/point"
     8  	"google.golang.org/protobuf/encoding/protojson"
     9  )
    10  
    11  func TestAddNode(t *testing.T) {
    12  	mg := &manager{
    13  		Manager: &node.Manager{},
    14  	}
    15  
    16  	mg.AddNode(&point.Point{
    17  		Hash:  "adadav",
    18  		Name:  "feefe",
    19  		Group: "group",
    20  	})
    21  	mg.AddNode(&point.Point{
    22  		Hash:  "adadab",
    23  		Name:  "fafaf",
    24  		Group: "group",
    25  	})
    26  	mg.AddNode(&point.Point{
    27  		Hash:  "adada",
    28  		Name:  "fazczfzf",
    29  		Group: "group",
    30  	})
    31  
    32  	t.Log(mg.Manager)
    33  
    34  	mg.AddTag("test_tag", 1, "adadab")
    35  	mg.AddTag("test_tag3", 0, "adada")
    36  	mg.AddTag("test_tag2", 0, "adadab")
    37  	mg.AddTag("test_tag2", 0, "adada")
    38  	mg.DeleteTag("test_tag2")
    39  	mg.DeleteNode("adada")
    40  
    41  	data, _ := protojson.MarshalOptions{Indent: "  "}.Marshal(mg.Manager)
    42  	// data2, _ := json.MarshalIndent(mg.Manager, "", " ")
    43  	t.Log(string(data))
    44  }