1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00
go-micro/client/grpc/request_test.go

42 lines
650 B
Go
Raw Normal View History

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