MCPcopy Create free account
hub / github.com/Facets-cloud/flow / TestTranscriptCmdWithSession

Function TestTranscriptCmdWithSession

internal/app/transcript_test.go:37–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestTranscriptCmdWithSession(t *testing.T) {
38 tmp := t.TempDir()
39 t.Setenv("FLOW_ROOT", filepath.Join(tmp, "flow"))
40 t.Setenv("HOME", tmp)
41
42 oldOsa := iterm.Runner
43 iterm.Runner = func(args []string) error { return nil }
44 t.Cleanup(func() { iterm.Runner = oldOsa })
45
46 cmdInit(nil)
47
48 repo := filepath.Join(tmp, "code", "myrepo")
49 os.MkdirAll(repo, 0o755)
50 cmdAdd([]string{"task", "Transcript Test", "--slug", "tx-test", "--work-dir", repo})
51
52 // Simulate session bootstrap.
53 dbPath, _ := flowDBPath()
54 db, _ := flowdb.OpenDB(dbPath)
55 defer db.Close()
56
57 sid := "deadbeef-1234-5678-9abc-def012345678"
58 now := flowdb.NowISO()
59 db.Exec(`UPDATE tasks SET session_id=?, session_started=?, updated_at=? WHERE slug=?`,
60 sid, now, now, "tx-test")
61
62 // Write a minimal jsonl at the claude convention path.
63 encoded := claude.EncodeCwd(repo)
64 sessionDir := filepath.Join(tmp, ".claude", "projects", encoded)
65 os.MkdirAll(sessionDir, 0o755)
66 os.WriteFile(
67 filepath.Join(sessionDir, sid+".jsonl"),
68 []byte(`{"type":"user","message":{"role":"user","content":"test message"},"uuid":"u1","timestamp":"2026-04-12T10:00:00Z","sessionId":"`+sid+`"}`+"\n"),
69 0o644,
70 )
71
72 rc := cmdTranscript([]string{"tx-test"})
73 if rc != 0 {
74 t.Errorf("transcript with session: rc=%d, want 0", rc)
75 }
76}
77
78// TestTranscriptRetrospectiveBindFullOutput pins the bug this task
79// fixes: a retrospective `flow do --here` bind stamps session_started

Callers

nothing calls this directly

Calls 7

OpenDBFunction · 0.92
NowISOFunction · 0.92
EncodeCwdFunction · 0.92
cmdInitFunction · 0.85
cmdAddFunction · 0.85
flowDBPathFunction · 0.85
cmdTranscriptFunction · 0.85

Tested by

no test coverage detected