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

Method TestParseConfigErrors

balancer/rls/config_test.go:215–515  ·  view source on GitHub ↗

TestParseConfigErrors verifies config parsing failure scenarios.

(t *testing.T)

Source from the content-addressed store, hash-verified

213
214// TestParseConfigErrors verifies config parsing failure scenarios.
215func (s) TestParseConfigErrors(t *testing.T) {
216 tests := []struct {
217 desc string
218 input []byte
219 wantErr string
220 }{
221 {
222 desc: "empty input",
223 input: nil,
224 wantErr: "rls: json unmarshal failed for service config",
225 },
226 {
227 desc: "bad json",
228 input: []byte(`bad bad json`),
229 wantErr: "rls: json unmarshal failed for service config",
230 },
231 {
232 desc: "bad grpcKeyBuilder",
233 input: []byte(`{
234 "routeLookupConfig": {
235 "grpcKeybuilders": [{
236 "names": [{"service": "service", "method": "method"}],
237 "headers": [{"key": "k1", "requiredMatch": true, "names": ["v1"]}]
238 }]
239 }
240 }`),
241 wantErr: "rls: GrpcKeyBuilder in RouteLookupConfig has required_match field set",
242 },
243 {
244 desc: "empty lookup service",
245 input: []byte(`{
246 "routeLookupConfig": {
247 "grpcKeybuilders": [{
248 "names": [{"service": "service", "method": "method"}],
249 "headers": [{"key": "k1", "names": ["v1"]}]
250 }]
251 }
252 }`),
253 wantErr: "rls: empty lookup_service in route lookup config",
254 },
255 {
256 desc: "unregistered scheme in lookup service URI",
257 input: []byte(`{
258 "routeLookupConfig": {
259 "grpcKeybuilders": [{
260 "names": [{"service": "service", "method": "method"}],
261 "headers": [{"key": "k1", "names": ["v1"]}]
262 }],
263 "lookupService": "badScheme:///target"
264 }
265 }`),
266 wantErr: "rls: unregistered scheme in lookup_service",
267 },
268 {
269 desc: "invalid lookup service timeout",
270 input: []byte(`{
271 "routeLookupConfig": {
272 "grpcKeybuilders": [{

Callers

nothing calls this directly

Calls 2

ParseConfigMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected