Кирилл Горбунов
ce57938ec2
Co-authored-by: Gorbunov Kirill Andreevich <kgorbunov@mtsbank.ru> Reviewed-on: #5 Co-authored-by: Кирилл Горбунов <kirya_gorbunov_2015@mail.ru> Co-committed-by: Кирилл Горбунов <kirya_gorbunov_2015@mail.ru>
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
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)
|
|
}
|