32 lines
819 B
Go
32 lines
819 B
Go
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)
|
|
}
|
|
|
|
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)
|
|
}
|