MCPcopy Create free account
hub / github.com/docker/docker-agent / TestForkSession_OutOfRange

Function TestForkSession_OutOfRange

pkg/server/session_manager_test.go:468–490  ·  view source on GitHub ↗

TestForkSession_OutOfRange covers the validation boundary: negative, past-the-end, and equal-to-count ordinals must all fail with ErrForkOutOfRange. The equal-to-count case is the regression guard for the dropped full-clone shortcut.

(t *testing.T)

Source from the content-addressed store, hash-verified

466// ErrForkOutOfRange. The equal-to-count case is the regression guard
467// for the dropped full-clone shortcut.
468func TestForkSession_OutOfRange(t *testing.T) {
469 t.Parallel()
470
471 ctx := t.Context()
472 store := session.NewInMemorySessionStore()
473 parent := session.New()
474 parent.Messages = []session.Item{session.NewMessageItem(session.UserMessage("hello"))}
475 require.NoError(t, store.AddSession(ctx, parent))
476
477 sm := NewSessionManager(ctx, config.Sources{}, store, 0, &config.RuntimeConfig{})
478
479 _, err := sm.ForkSession(ctx, parent.ID, -1)
480 require.ErrorIs(t, err, ErrForkOutOfRange)
481
482 _, err = sm.ForkSession(ctx, parent.ID, 5)
483 require.ErrorIs(t, err, ErrForkOutOfRange)
484
485 // Equal to the visible user-message count: previously a silent full
486 // clone, now an explicit ErrForkOutOfRange so the contract stays
487 // "anchor on a real user turn".
488 _, err = sm.ForkSession(ctx, parent.ID, 1)
489 require.ErrorIs(t, err, ErrForkOutOfRange)
490}
491
492// TestForkSession_DeepCopyIsolatesParent verifies that mutating the
493// forked session's messages does not leak back into the parent: this is

Callers

nothing calls this directly

Calls 8

AddSessionMethod · 0.95
ForkSessionMethod · 0.95
NewInMemorySessionStoreFunction · 0.92
NewFunction · 0.92
NewMessageItemFunction · 0.92
UserMessageFunction · 0.92
NewSessionManagerFunction · 0.85
ContextMethod · 0.80

Tested by

no test coverage detected