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

Function TestIsStreamTruncationError

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

Source from the content-addressed store, hash-verified

476}
477
478func TestIsStreamTruncationError(t *testing.T) {
479 t.Parallel()
480
481 tests := []struct {
482 name string
483 err error
484 expected bool
485 }{
486 {name: "nil error", err: nil, expected: false},
487 {name: "unexpected end of JSON input", err: errors.New("unexpected end of JSON input"), expected: true},
488 {name: "unexpected EOF", err: errors.New("unexpected EOF"), expected: true},
489 {name: "mixed case", err: errors.New("Unexpected EOF"), expected: true},
490 {name: "wrapped by stream layer", err: fmt.Errorf("error receiving from stream: %w", errors.New("unexpected end of JSON input")), expected: true},
491 // Context teardown must NOT be claimed as an upstream truncation, even
492 // if the message happens to mention EOF-ish text.
493 {name: "context canceled", err: context.Canceled, expected: false},
494 {name: "context deadline", err: context.DeadlineExceeded, expected: false},
495 {name: "clean EOF is not a truncation signature", err: errors.New("EOF"), expected: false},
496 {name: "unrelated error", err: errors.New("connection refused"), expected: false},
497 }
498
499 for _, tt := range tests {
500 t.Run(tt.name, func(t *testing.T) {
501 t.Parallel()
502 assert.Equal(t, tt.expected, IsStreamTruncationError(tt.err), "IsStreamTruncationError(%v)", tt.err)
503 })
504 }
505}
506
507func TestFormatError(t *testing.T) {
508 t.Parallel()

Callers

nothing calls this directly

Calls 3

IsStreamTruncationErrorFunction · 0.85
RunMethod · 0.65
NewMethod · 0.45

Tested by

no test coverage detected