1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-12 08:23:58 +02:00
go-micro/client/grpc/request_test.go

49 lines
836 B
Go
Raw Normal View History

2019-06-03 19:44:43 +02:00
package grpc
import (
"testing"
pb "google.golang.org/grpc/examples/helloworld/helloworld"
)
func TestMethodToGRPC(t *testing.T) {
testData := []struct {
method string
expect string
request interface{}
}{
{
"Greeter.SayHello",
"/helloworld.Greeter/SayHello",
new(pb.HelloRequest),
},
{
"/helloworld.Greeter/SayHello",
"/helloworld.Greeter/SayHello",
new(pb.HelloRequest),
},
{
"Greeter.SayHello",
"/helloworld.Greeter/SayHello",
pb.HelloRequest{},
},
{
"/helloworld.Greeter/SayHello",
"/helloworld.Greeter/SayHello",
pb.HelloRequest{},
},
{
"Greeter.SayHello",
"Greeter.SayHello",
nil,
},
}
for _, d := range testData {
method := methodToGRPC(d.method, d.request)
if method != d.expect {
t.Fatalf("expected %s got %s", d.expect, method)
}
}
}