Skip to content

Commit e313f91

Browse files
wesmclaude
andcommitted
test: cover generic error paths in waitMultiple reporting
Add table-driven tests for the default branch in waitMultiple's per-job error reporting: failed jobs, canceled jobs, and review fetch errors (done status with missing review). These paths were untested despite being central to the fix in the previous commit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f264571 commit e313f91

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

cmd/roborev/wait_test.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,74 @@ func TestWaitMultipleJobIDsNotFoundReportsOutput(t *testing.T) {
377377
}
378378
}
379379

380+
func TestWaitMultipleGenericErrors(t *testing.T) {
381+
setupFastPolling(t)
382+
383+
cases := []struct {
384+
name string
385+
jobs map[int64]mockJobResult
386+
args []string
387+
wantMsg string // substring expected in stdout for the failing job
388+
}{
389+
{
390+
name: "failed job reports error message",
391+
jobs: map[int64]mockJobResult{
392+
10: {
393+
job: storage.ReviewJob{ID: 10, Agent: "test", Status: "done"},
394+
review: &storage.Review{ID: 1, JobID: 10, Agent: "test", Output: "No issues found."},
395+
},
396+
20: {
397+
job: storage.ReviewJob{ID: 20, Agent: "test", Status: "failed", Error: "agent crashed"},
398+
},
399+
},
400+
args: []string{"--job", "10", "20"},
401+
wantMsg: "Job 20: review failed: agent crashed",
402+
},
403+
{
404+
name: "canceled job reports canceled",
405+
jobs: map[int64]mockJobResult{
406+
10: {
407+
job: storage.ReviewJob{ID: 10, Agent: "test", Status: "done"},
408+
review: &storage.Review{ID: 1, JobID: 10, Agent: "test", Output: "No issues found."},
409+
},
410+
30: {
411+
job: storage.ReviewJob{ID: 30, Agent: "test", Status: "canceled"},
412+
},
413+
},
414+
args: []string{"--job", "10", "30"},
415+
wantMsg: "Job 30: review was canceled",
416+
},
417+
{
418+
name: "review fetch error reports message",
419+
jobs: map[int64]mockJobResult{
420+
10: {
421+
job: storage.ReviewJob{ID: 10, Agent: "test", Status: "done"},
422+
review: &storage.Review{ID: 1, JobID: 10, Agent: "test", Output: "No issues found."},
423+
},
424+
40: {
425+
job: storage.ReviewJob{ID: 40, Agent: "test", Status: "done"},
426+
// review is nil → /api/review returns 404
427+
},
428+
},
429+
args: []string{"--job", "10", "40"},
430+
wantMsg: "Job 40: no review found",
431+
},
432+
}
433+
434+
for _, tc := range cases {
435+
t.Run(tc.name, func(t *testing.T) {
436+
handler := newMultiJobMockHandler(tc.jobs)
437+
newWaitEnv(t, handler)
438+
439+
stdout, err := runWait(t, tc.args...)
440+
requireExitCode(t, err, 1)
441+
if !strings.Contains(stdout, tc.wantMsg) {
442+
t.Errorf("expected stdout to contain %q, got: %q", tc.wantMsg, stdout)
443+
}
444+
})
445+
}
446+
}
447+
380448
func TestWaitMultipleValidationBeforeDaemon(t *testing.T) {
381449
// Validation errors for --job should surface before contacting
382450
// the daemon. This test does NOT start a mock daemon.

0 commit comments

Comments
 (0)