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

Function TestContextOverflowError

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

Source from the content-addressed store, hash-verified

399}
400
401func TestContextOverflowError(t *testing.T) {
402 t.Parallel()
403
404 t.Run("wraps underlying error", func(t *testing.T) {
405 t.Parallel()
406 underlying := errors.New("prompt is too long: 226360 tokens > 200000 maximum")
407 ctxErr := NewContextOverflowError(underlying)
408
409 assert.Contains(t, ctxErr.Error(), "context window overflow")
410 assert.Contains(t, ctxErr.Error(), "prompt is too long")
411 assert.ErrorIs(t, ctxErr, underlying)
412 })
413
414 t.Run("nil underlying returns fallback message", func(t *testing.T) {
415 t.Parallel()
416 ctxErr := NewContextOverflowError(nil)
417 assert.Equal(t, "context window overflow", ctxErr.Error())
418 assert.NoError(t, ctxErr.Unwrap())
419 })
420
421 t.Run("errors.As works through wrapping", func(t *testing.T) {
422 t.Parallel()
423 underlying := errors.New("test error")
424 wrapped := fmt.Errorf("all models failed: %w", NewContextOverflowError(underlying))
425
426 var ctxErr *ContextOverflowError
427 require.ErrorAs(t, wrapped, &ctxErr)
428 assert.Equal(t, underlying, ctxErr.Underlying)
429 })
430}
431
432func TestIsRetryableModelError_ContextOverflow(t *testing.T) {
433 t.Parallel()

Callers

nothing calls this directly

Calls 5

ErrorMethod · 0.95
UnwrapMethod · 0.95
NewContextOverflowErrorFunction · 0.85
RunMethod · 0.65
NewMethod · 0.45

Tested by

no test coverage detected