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

Function TestRunSessionList_JSON

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
captureStdoutFunction · 0.85
runSessionListFunction · 0.85
RecordReviewItemDoneMethod · 0.80
FinalizeMethod · 0.80

Tested by

no test coverage detected