github.com/annwntech/go-micro/v2@v2.9.5/client/grpc/request_test.go (about)

     1  package grpc
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestMethodToGRPC(t *testing.T) {
     8  	testData := []struct {
     9  		service string
    10  		method  string
    11  		expect  string
    12  	}{
    13  		{
    14  			"helloworld",
    15  			"Greeter.SayHello",
    16  			"/helloworld.Greeter/SayHello",
    17  		},
    18  		{
    19  			"helloworld",
    20  			"/helloworld.Greeter/SayHello",
    21  			"/helloworld.Greeter/SayHello",
    22  		},
    23  		{
    24  			"",
    25  			"/helloworld.Greeter/SayHello",
    26  			"/helloworld.Greeter/SayHello",
    27  		},
    28  		{
    29  			"",
    30  			"Greeter.SayHello",
    31  			"/Greeter/SayHello",
    32  		},
    33  	}
    34  
    35  	for _, d := range testData {
    36  		method := methodToGRPC(d.service, d.method)
    37  		if method != d.expect {
    38  			t.Fatalf("expected %s got %s", d.expect, method)
    39  		}
    40  	}
    41  }