增加节点停止、启动、安装测试等功能

This commit is contained in:
GoEdgeLab
2020-10-27 12:33:34 +08:00
parent f22c228a69
commit 5b0ed31f2d
5 changed files with 113 additions and 4 deletions

View File

@@ -1,11 +1,50 @@
package nodes
import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/golang/protobuf/proto"
_ "github.com/iwind/TeaGo/bootstrap"
"io"
"strconv"
"testing"
)
func TestNode(t *testing.T) {
func TestNode_Start(t *testing.T) {
node := NewNode()
node.Start()
}
func TestNode_Test(t *testing.T) {
node := NewNode()
err := node.Test()
if err != nil {
t.Fatal(err)
}
t.Log("ok")
}
func TestNode_Proto_Buffer(t *testing.T) {
buff := proto.NewBuffer([]byte{})
for i := 0; i < 10; i++ {
err := buff.EncodeMessage(&pb.NodeStreamMessage{
RequestId: int64(i),
Code: "msg" + strconv.Itoa(i),
})
if err != nil {
t.Fatal(err)
}
}
for i := 0; i < 11; i++ {
msg := &pb.NodeStreamMessage{}
err := buff.DecodeMessage(msg)
if err != nil {
if err == io.EOF || err == io.ErrUnexpectedEOF {
break
} else {
t.Fatal(err)
}
}
t.Log(msg.Code, msg.RequestId)
}
}