MCPcopy
hub / github.com/grpc-ecosystem/grpc-gateway / TestParseSegmentsWithErrors

Function TestParseSegmentsWithErrors

internal/httprule/parse_test.go:371–438  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

369}
370
371func TestParseSegmentsWithErrors(t *testing.T) {
372 for _, spec := range []struct {
373 tokens []string
374 }{
375 {
376 // double slash
377 tokens: []string{"//", eof},
378 },
379 {
380 // invalid literal
381 tokens: []string{"a?b", eof},
382 },
383 {
384 // invalid percent-encoding
385 tokens: []string{"%", eof},
386 },
387 {
388 // invalid percent-encoding
389 tokens: []string{"%2", eof},
390 },
391 {
392 // invalid percent-encoding
393 tokens: []string{"a%2z", eof},
394 },
395 {
396 // unterminated variable
397 tokens: []string{"{", "name", eof},
398 },
399 {
400 // unterminated variable
401 tokens: []string{"{", "name", "=", eof},
402 },
403 {
404 // unterminated variable
405 tokens: []string{"{", "name", "=", "*", eof},
406 },
407 {
408 // empty component in field path
409 tokens: []string{"{", "name", ".", "}", eof},
410 },
411 {
412 // empty component in field path
413 tokens: []string{"{", "name", ".", ".", "nested", "}", eof},
414 },
415 {
416 // invalid character in identifier
417 tokens: []string{"{", "field-name", "}", eof},
418 },
419 {
420 // no slash between segments
421 tokens: []string{"v1", "endpoint", eof},
422 },
423 {
424 // no slash between segments
425 tokens: []string{"v1", "{", "name", "}", eof},
426 },
427 } {
428 p := parser{tokens: spec.tokens}

Callers

nothing calls this directly

Calls 1

topLevelSegmentsMethod · 0.95

Tested by

no test coverage detected