MCPcopy Create free account
hub / github.com/JordanCoin/codemap / TestRunHandoffSubcommandLatestVariants

Function TestRunHandoffSubcommandLatestVariants

main_helpers_test.go:51–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestRunHandoffSubcommandLatestVariants(t *testing.T) {
52 root := t.TempDir()
53 if err := os.MkdirAll(filepath.Join(root, ".codemap"), 0o755); err != nil {
54 t.Fatal(err)
55 }
56
57 artifact := &handoff.Artifact{
58 SchemaVersion: handoff.SchemaVersion,
59 Branch: "feature/test",
60 BaseRef: "main",
61 Prefix: handoff.PrefixSnapshot{FileCount: 3},
62 Delta: handoff.DeltaSnapshot{
63 Changed: []handoff.FileStub{{Path: "main.go", Status: "modified", Size: 42}},
64 RecentEvents: []handoff.EventSummary{{
65 Time: time.Date(2026, time.March, 9, 12, 0, 0, 0, time.UTC),
66 Op: "WRITE",
67 Path: "main.go",
68 Delta: 2,
69 }},
70 },
71 }
72 if err := handoff.WriteLatest(root, artifact); err != nil {
73 t.Fatalf("WriteLatest error: %v", err)
74 }
75
76 state := watch.State{
77 UpdatedAt: time.Now(),
78 Importers: map[string][]string{"main.go": {"a.go", "b.go", "c.go"}},
79 Imports: map[string][]string{"main.go": {"dep.go"}},
80 }
81 data, err := json.Marshal(state)
82 if err != nil {
83 t.Fatal(err)
84 }
85 if err := os.WriteFile(filepath.Join(root, ".codemap", "state.json"), data, 0o644); err != nil {
86 t.Fatal(err)
87 }
88
89 prefixJSON := captureMainOutput(func() { runHandoffSubcommand([]string{"--latest", "--prefix", "--json", root}) })
90 if !strings.Contains(prefixJSON, "\"file_count\": 3") {
91 t.Fatalf("expected prefix JSON output, got:\n%s", prefixJSON)
92 }
93
94 deltaOut := captureMainOutput(func() { runHandoffSubcommand([]string{"--latest", "--delta", root}) })
95 if !strings.Contains(deltaOut, "## Handoff Delta") || !strings.Contains(deltaOut, "`main.go` (modified)") {
96 t.Fatalf("expected delta markdown output, got:\n%s", deltaOut)
97 }
98
99 detailOut := captureMainOutput(func() { runHandoffSubcommand([]string{"--latest", "--detail", "main.go", root}) })
100 checks := []string{"## Handoff File Detail", "`dep.go`", "`a.go`", "`b.go`", "`c.go`"}
101 for _, check := range checks {
102 if !strings.Contains(detailOut, check) {
103 t.Fatalf("expected detail output to contain %q, got:\n%s", check, detailOut)
104 }
105 }
106}
107
108func TestRunWatchSubcommandInactiveCases(t *testing.T) {

Callers

nothing calls this directly

Calls 3

WriteLatestFunction · 0.92
captureMainOutputFunction · 0.85
runHandoffSubcommandFunction · 0.85

Tested by

no test coverage detected