1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-18 08:26:38 +02:00
go-micro/client/grpc/request_test.go
2019-06-03 18:44:43 +01:00

49 lines
836 B
Go

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)
}
}
}