(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func 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 | |
| 39 | func TestSaveCheckpointMaxLimit(t *testing.T) { |
| 40 | cli := &ChatCLI{ |
nothing calls this directly
no test coverage detected