Skip to content

Commit 4ead18d

Browse files
mchwangclaude
andcommitted
Read the holder test's sweep warnings before restoring the spy (#189)
Review round 42: mockRestore clears the recorded calls, so the check that the sweep says nothing of a gone holder read an empty list and could not fail; the calls are copied first, and the test also checks the spy saw the sweep's own lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c6cac80 commit 4ead18d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎test/agent-container.test.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,14 @@ describe('real Docker agent isolation', () => {
833833
`exec '${realDocker}' "$@"`].join('\n'), { mode: 0o755 });
834834
// And it says nothing of that gone holder: Docker's own answer is not a failure.
835835
const sweepWarn = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
836-
try { removeLabelledObjects(TEST_RUN_LABEL, run, 'test', join(shim, 'docker')); } finally { sweepWarn.mockRestore(); }
837-
expect(sweepWarn.mock.calls.filter(call => String(call[0]).endsWith('failed:'))).toEqual([]);
836+
// Copied before the restore, which clears the calls.
837+
let sweepCalls: unknown[][] = [];
838+
try {
839+
removeLabelledObjects(TEST_RUN_LABEL, run, 'test', join(shim, 'docker'));
840+
sweepCalls = [...sweepWarn.mock.calls];
841+
} finally { sweepWarn.mockRestore(); }
842+
expect(sweepCalls.filter(call => String(call[0]).endsWith('failed:'))).toEqual([]);
843+
expect(sweepCalls.length).toBeGreaterThan(0);
838844
// afterAll removes tracked names with removeByName, as here: an object of exactly that name goes, and a name that
839845
// is gone says nothing.
840846
const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined);

0 commit comments

Comments
 (0)