MCPcopy
hub / github.com/grpc/grpc-go / TestParseMethodConfigAndSuffix

Method TestParseMethodConfigAndSuffix

internal/binarylog/env_config_test.go:93–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

91}
92
93func (s) TestParseMethodConfigAndSuffix(t *testing.T) {
94 testCases := []struct {
95 in, service, method, suffix string
96 }{
97 {
98 in: "p.s/m",
99 service: "p.s", method: "m", suffix: "",
100 },
101 {
102 in: "p.s/m{h,m}",
103 service: "p.s", method: "m", suffix: "{h,m}",
104 },
105 {
106 in: "p.s/*",
107 service: "p.s", method: "*", suffix: "",
108 },
109 {
110 in: "p.s/*{h,m}",
111 service: "p.s", method: "*", suffix: "{h,m}",
112 },
113
114 // invalid suffix will be detected by another function.
115 {
116 in: "p.s/m{invalidsuffix}",
117 service: "p.s", method: "m", suffix: "{invalidsuffix}",
118 },
119 {
120 in: "p.s/*{invalidsuffix}",
121 service: "p.s", method: "*", suffix: "{invalidsuffix}",
122 },
123 {
124 in: "s/m*",
125 service: "s", method: "m", suffix: "*",
126 },
127 {
128 in: "s/*m",
129 service: "s", method: "*", suffix: "m",
130 },
131 {
132 in: "s/**",
133 service: "s", method: "*", suffix: "*",
134 },
135 }
136 for _, tc := range testCases {
137 t.Logf("testing parseMethodConfigAndSuffix(%q)", tc.in)
138 s, m, suffix, err := parseMethodConfigAndSuffix(tc.in)
139 if err != nil {
140 t.Errorf("returned error %v, want nil", err)
141 continue
142 }
143 if s != tc.service {
144 t.Errorf("service = %q, want %q", s, tc.service)
145 }
146 if m != tc.method {
147 t.Errorf("method = %q, want %q", m, tc.method)
148 }
149 if suffix != tc.suffix {
150 t.Errorf("suffix = %q, want %q", suffix, tc.suffix)

Callers

nothing calls this directly

Calls 3

LogfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected