MCPcopy Create free account
hub / github.com/diillson/chatcli / TestSaveCheckpoint

Function TestSaveCheckpoint

cli/rewind_test.go:9–37  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestSaveCheckpoint(t *testing.T) {
10 cli := &ChatCLI{
11 history: []models.Message{
12 {Role: "system", Content: "sys"},
13 {Role: "user", Content: "hello"},
14 {Role: "assistant", Content: "hi there"},
15 },
16 }
17
18 cli.saveCheckpoint()
19
20 if len(cli.checkpoints) != 1 {
21 t.Fatalf("expected 1 checkpoint, got %d", len(cli.checkpoints))
22 }
23
24 cp := cli.checkpoints[0]
25 if cp.MsgCount != 3 {
26 t.Errorf("expected MsgCount=3, got %d", cp.MsgCount)
27 }
28 if cp.Label != "hello" {
29 t.Errorf("expected label='hello', got %q", cp.Label)
30 }
31
32 // Verify deep copy: modifying original should not affect checkpoint
33 cli.history = append(cli.history, models.Message{Role: "user", Content: "new msg"})
34 if len(cp.History) != 3 {
35 t.Error("checkpoint history should not be affected by original mutation")
36 }
37}
38
39func TestSaveCheckpointMaxLimit(t *testing.T) {
40 cli := &ChatCLI{

Callers

nothing calls this directly

Calls 3

saveCheckpointMethod · 0.95
ErrorfMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected