mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-12 08:23:58 +02:00
49 lines
836 B
Go
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)
|
||
|
}
|
||
|
}
|
||
|
}
|