fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

1package grpcutil 2 3import ( 4 "testing" 5 6 "github.com/google/go-cmp/cmp" 7) 8 9func TestSplitMethodName(t *testing.T) { 10 testCases := []struct { 11 name string 12 13 fullMethod string 14 wantService string 15 wantMethod string 16 }{ 17 { 18 name: "full method with service and method", 19 20 fullMethod: "/package.service/method", 21 wantService: "package.service", 22 wantMethod: "method", 23 }, 24 { 25 name: "method without leading slash", 26 27 fullMethod: "package.service/method", 28 wantService: "package.service", 29 wantMethod: "method", 30 }, 31 { 32 name: "service without method", 33 34 fullMethod: "/package.service/", 35 wantService: "package.service", 36 wantMethod: "", 37 }, 38 { 39 name: "empty input", 40 41 fullMethod: "", 42 wantService: "unknown", 43 wantMethod: "unknown", 44 }, 45 } 46 47 for _, tc := range testCases { 48 t.Run(tc.name, func(t *testing.T) { 49 service, method := SplitMethodName(tc.fullMethod) 50 if diff := cmp.Diff(service, tc.wantService); diff != "" { 51 t.Errorf("splitMethodName(%q) service (-want +got):\n%s", tc.fullMethod, diff) 52 } 53 54 if diff := cmp.Diff(method, tc.wantMethod); diff != "" { 55 t.Errorf("splitMethodName(%q) method (-want +got):\n%s", tc.fullMethod, diff) 56 } 57 }) 58 } 59}