gobuf/gobuf_test.go

32 lines
819 B
Go
Raw Normal View History

2023-03-20 17:08:22 +00:00
package gobuf
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParser_AddRPC(t *testing.T) {
parser, err := NewParser("example.proto")
assert.Nil(t, err)
existService := parser.ExistService("File")
assert.EqualValues(t, true, existService)
existRPC := parser.ExistRPC("File", "List")
assert.EqualValues(t, true, existRPC)
existRPC = parser.ExistRPC("File", "List1")
assert.EqualValues(t, false, existRPC)
existMsg := parser.ExistMessage("DeleteReq")
assert.EqualValues(t, true, existMsg)
err = parser.AddRPC("File", "UpdateUserInfo")
assert.Nil(t, err)
}
2023-03-20 17:20:24 +00:00
func TestParser_AddService(t *testing.T) {
parser, err := NewParser("example.proto")
assert.Nil(t, err)
err = parser.AddService("UserInfo")
assert.Nil(t, err)
err = parser.AddRPC("UserInfo", "Detail")
assert.Nil(t, err)
}