MCPcopy Index your code
hub / github.com/docker/docker-agent / TestMatchesTransientPattern

Function TestMatchesTransientPattern

pkg/modelerrors/modelerrors_test.go:453–476  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

451}
452
453func TestMatchesTransientPattern(t *testing.T) {
454 t.Parallel()
455
456 tests := []struct {
457 name string
458 err error
459 expected bool
460 }{
461 {name: "nil error", err: nil, expected: false},
462 {name: "unrelated error", err: errors.New("connection refused"), expected: false},
463 {name: "exact lowercase match", err: errors.New("number of function response parts"), expected: true},
464 // Defence-in-depth: the message is lowercased before comparison so
465 // mixed-case provider errors still match the lowercase pattern.
466 {name: "mixed-case message", err: errors.New("Please ensure that the Number Of Function Response Parts is equal"), expected: true},
467 {name: "wrapped error", err: fmt.Errorf("error receiving from stream: %w", errors.New("NUMBER OF FUNCTION RESPONSE PARTS")), expected: true},
468 }
469
470 for _, tt := range tests {
471 t.Run(tt.name, func(t *testing.T) {
472 t.Parallel()
473 assert.Equal(t, tt.expected, matchesTransientPattern(tt.err), "matchesTransientPattern(%v)", tt.err)
474 })
475 }
476}
477
478func TestIsStreamTruncationError(t *testing.T) {
479 t.Parallel()

Callers

nothing calls this directly

Calls 3

matchesTransientPatternFunction · 0.85
RunMethod · 0.65
NewMethod · 0.45

Tested by

no test coverage detected