micro/client/grpc/request_test.go

42 lines
650 B
Go
Raw Normal View History

2019-06-03 20:44:43 +03:00
package grpc
import (
"testing"
)
func TestMethodToGRPC(t *testing.T) {
testData := []struct {
2019-06-19 14:34:45 +03:00
service string
2019-06-03 20:44:43 +03:00
method string
expect string
}{
{
2019-06-19 14:34:45 +03:00
"helloworld",
2019-06-03 20:44:43 +03:00
"Greeter.SayHello",
"/helloworld.Greeter/SayHello",
},
{
2019-06-19 14:34:45 +03:00
"helloworld",
2019-06-03 20:44:43 +03:00
"/helloworld.Greeter/SayHello",
"/helloworld.Greeter/SayHello",
},
{
2019-06-19 14:34:45 +03:00
"",
2019-06-03 20:44:43 +03:00
"/helloworld.Greeter/SayHello",
"/helloworld.Greeter/SayHello",
},
{
2019-06-19 14:34:45 +03:00
"",
2019-06-03 20:44:43 +03:00
"Greeter.SayHello",
2019-06-19 14:34:45 +03:00
"/Greeter/SayHello",
2019-06-03 20:44:43 +03:00
},
}
for _, d := range testData {
2019-06-19 14:34:45 +03:00
method := methodToGRPC(d.service, d.method)
2019-06-03 20:44:43 +03:00
if method != d.expect {
t.Fatalf("expected %s got %s", d.expect, method)
}
}
}