package protoset import ( "fmt" "os" "testing" "github.com/stretchr/testify/assert" ) func TestProtoSet_1(t *testing.T) { p := NewProtoSet() data, err := os.ReadFile("path to .protoset") assert.Nil(t, err) err = p.AddProtoset("localhost:9090", "CardService", data) assert.Nil(t, err) req, rsp, err := p.GetMessage("localhost:9090", "card_proto", "CardService", "GetCardList") assert.Nil(t, err) assert.NotNil(t, req) assert.NotNil(t, rsp) fmt.Printf("req: %v, rsp: %v \n", req, rsp) } func TestProtoSet_2_bad(t *testing.T) { p := NewProtoSet() data, err := os.ReadFile("path to .protoset") assert.Nil(t, err) err = p.AddProtoset("localhost:9090", "CardService", data) assert.Nil(t, err) req, rsp, err := p.GetMessage("localhost:9090", "card_proto", "Card", "GetCardList") assert.Error(t, err) assert.Nil(t, req) assert.Nil(t, rsp) fmt.Printf("req: %v, rsp: %v \n", req, rsp) } func TestProtoSet_3_not_found(t *testing.T) { p := NewProtoSet() req, rsp, err := p.GetMessage("localhost:9090", "card_proto", "CardService", "GetCardList") assert.ErrorIs(t, err, errNotFound) assert.Nil(t, req) assert.Nil(t, rsp) fmt.Printf("req: %v, rsp: %v \n", req, rsp) }