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