checkpoint resume: integration tests · Entire

checkpoint resume: integration tests

b702fd7main·

pfleidi·1w ago·1 file·+76 added/-0 removed

Cover the by-ID resume flow (branch checkout via checkpoint index) and the non-TTY bare listing end-to-end with the spawned binary.

Sessions

01KX1EDSKA7BA4R9RTSAAWWFSCView transcript

[?
Implement Checkpoint Resume CommandClaude Code·2 steps](/content/gh/entireio/cli/session/ba137a72-eaf9-443b-b868-49da78b39915#timeline-01KX1EDSKA7BA4R9RTSAAWWFSC/index.html)

Changes

1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

//go:build integration

package integration

import (
    "strings"
    "testing"
)

// TestCheckpointResume_ByCheckpointID resumes a checkpoint by ID from another
// branch: the CLI must find the branch containing the checkpoint's commit,
// check it out, and restore the session log.
func TestCheckpointResume_ByCheckpointID(t *testing.T) {
    t.Parallel()
    env := NewFeatureBranchEnv(t)

session := env.NewSession()
    if err := env.SimulateUserPromptSubmit(session.ID); err != nil {
        t.Fatalf("SimulateUserPromptSubmit failed: %%v", err)
    }
    content := "puts 'resume by id'"
    env.WriteFile("hello.rb", content)
    session.CreateTranscript(
        "Create a hello script",
        []FileChange{{Path: "hello.rb", Content: content}},
    )
    if err := env.SimulateStop(session.ID, session.TranscriptPath); err != nil {
        t.Fatalf("SimulateStop failed: %%v", err)
    }
    env.GitCommitWithShadowHooks("Create a hello script", "hello.rb")

featureBranch := env.GetCurrentBranch()
    checkpointID := env.GetLatestCheckpointID()
    env.GitCheckoutBranch(masterBranch)

output := env.RunCLI("checkpoint", "resume", checkpointID)

if branch := env.GetCurrentBranch(); branch != featureBranch {
        t.Errorf("expected to be on %%s, got %%s\noutput: %%s", featureBranch, branch, output)
    }
    if !strings.Contains(output, session.ID) {
        t.Errorf("output should reference restored session %%s, got: %%s", session.ID, output)
    }
}

// TestCheckpointResume_BareNonTTY verifies the agent-safe fallback: with no
// target and no TTY, the command lists recent checkpoints with full IDs.
func TestCheckpointResume_BareNonTTY(t *testing.T) {
    t.Parallel()
    env := NewFeatureBranchEnv(t)

session := env.NewSession()
    if err := env.SimulateUserPromptSubmit(session.ID); err != nil {
        t.Fatalf("SimulateUserPromptSubmit failed: %%v", err)
    }
    content := "puts 'bare listing'"
    env.WriteFile("list.rb", content)
    session.CreateTranscript(
        "Create a listing script",
        []FileChange{{Path: "list.rb", Content: content}},
    )
    if err := env.SimulateStop(session.ID, session.TranscriptPath); err != nil {
        t.Fatalf("SimulateStop failed: %%v", err)
    }
    env.GitCommitWithShadowHooks("Create a listing script", "list.rb")

checkpointID := env.GetLatestCheckpointID()
    output := env.RunCLI("checkpoint", "resume")

if !strings.Contains(output, checkpointID) {
        t.Errorf("bare listing should contain full checkpoint ID %%s, got: %%s", checkpointID, output)
    }
    if !strings.Contains(output, "entire checkpoint resume <checkpoint-id>") {
        t.Errorf("bare listing should include the resume hint, got: %%s", output)
    }
}