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