MCPcopy Create free account
hub / github.com/alibaba/open-code-review / TestRunSessionList_JSON

Function TestRunSessionList_JSON

cmd/opencodereview/session_cmd_test.go:50–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

48}
49
50func TestRunSessionList_JSON(t *testing.T) {
51 tmpHome := t.TempDir()
52 setTestHome(t, tmpHome)
53 repoDir := t.TempDir()
54
55 sh := session.New(repoDir, "main", "test-model", session.SessionOptions{
56 ReviewMode: session.ReviewModeCommit,
57 DiffCommit: "abc123",
58 })
59 sh.RecordReviewItemDone("a.go", "a.go", "a.go", "fp-a", nil)
60 sh.Finalize()
61
62 got := captureStdout(t, func() {
63 if err := runSessionListCompat([]string{"--repo", repoDir, "--json"}); err != nil {
64 t.Fatalf("runSessionList: %v", err)
65 }
66 })
67
68 var decoded []session.Summary
69 if err := json.Unmarshal([]byte(got), &decoded); err != nil {
70 t.Fatalf("unmarshal: %v (out=%q)", err, got)
71 }
72 if len(decoded) != 1 || decoded[0].SessionID != sh.SessionID {
73 t.Fatalf("decoded = %+v", decoded)
74 }
75}
76
77func TestRunSessionList_EmptyRepo(t *testing.T) {
78 tmpHome := t.TempDir()

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
runSessionListCompatFunction · 0.85
RecordReviewItemDoneMethod · 0.80
setTestHomeFunction · 0.70
captureStdoutFunction · 0.70
FinalizeMethod · 0.45

Tested by

no test coverage detected