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)
| 466 | // ErrForkOutOfRange. The equal-to-count case is the regression guard |
| 467 | // for the dropped full-clone shortcut. |
| 468 | func 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 |
nothing calls this directly
no test coverage detected