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

Function TestRunSessionShow_JSON

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

Source from the content-addressed store, hash-verified

270}
271
272func TestRunSessionShow_JSON(t *testing.T) {
273 tmpHome := t.TempDir()
274 setTestHome(t, tmpHome)
275 repoDir := t.TempDir()
276
277 sh := session.New(repoDir, "main", "test-model", session.SessionOptions{
278 ReviewMode: session.ReviewModeCommit,
279 DiffCommit: "abc123",
280 })
281 sh.RecordReviewItemDone("a.go", "a.go", "a.go", "fp-a", nil)
282 sh.Finalize()
283
284 got := captureStdout(t, func() {
285 if err := runSessionShowCompat([]string{"--repo", repoDir, "--json", sh.SessionID}); err != nil {
286 t.Fatalf("runSessionShow: %v", err)
287 }
288 })
289
290 var payload struct {
291 Summary *session.Summary `json:"summary"`
292 Items []session.ItemDetail `json:"items"`
293 }
294 if err := json.Unmarshal([]byte(got), &payload); err != nil {
295 t.Fatalf("unmarshal: %v (out=%q)", err, got)
296 }
297 if payload.Summary == nil || payload.Summary.SessionID != sh.SessionID {
298 t.Fatalf("summary mismatch: %+v", payload.Summary)
299 }
300 if len(payload.Items) != 1 || payload.Items[0].FilePath != "a.go" {
301 t.Fatalf("items = %+v", payload.Items)
302 }
303}
304
305func TestRunSessionComments_TextRendersLikeReview(t *testing.T) {
306 tmpHome := t.TempDir()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected