Skip to content

Commit 9288611

Browse files
committed
test(coverage): cover coanaFix upload + missing-tar-hash error paths
Adds two more tests for early-return error branches in coanaFix: - handleApiCall (manifest upload) failure → returns the upload error result (line 150) - Upload succeeds but the server returns no tarHash → 'No tar hash returned from Socket API' error (lines 154-160) coana-fix.mts: 60.67% → 61.92% statements.
1 parent 1c681da commit 9288611

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

packages/cli/test/unit/commands/fix/handle-fix-limit.test.mts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,5 +524,43 @@ describe('socket fix --limit behavior verification', () => {
524524
}
525525
expect(mockSpawnCoanaDlx).not.toHaveBeenCalled()
526526
})
527+
528+
it('returns upload error when manifest upload fails (line 150)', async () => {
529+
mockHandleApiCall.mockResolvedValueOnce({
530+
ok: false,
531+
message: 'Upload Failed',
532+
cause: 'Bad gateway',
533+
})
534+
535+
const result = await coanaFix({
536+
...baseConfig,
537+
ghsas: ['GHSA-1111-1111-1111'],
538+
})
539+
540+
expect(result.ok).toBe(false)
541+
if (!result.ok) {
542+
expect(result.message).toBe('Upload Failed')
543+
}
544+
expect(mockSpawnCoanaDlx).not.toHaveBeenCalled()
545+
})
546+
547+
it('returns error when upload returns no tar hash (lines 154-160)', async () => {
548+
mockHandleApiCall.mockResolvedValueOnce({
549+
ok: true,
550+
// No tarHash in payload — server contract violation.
551+
data: {},
552+
})
553+
554+
const result = await coanaFix({
555+
...baseConfig,
556+
ghsas: ['GHSA-1111-1111-1111'],
557+
})
558+
559+
expect(result.ok).toBe(false)
560+
if (!result.ok) {
561+
expect(result.message).toContain('tar hash')
562+
}
563+
expect(mockSpawnCoanaDlx).not.toHaveBeenCalled()
564+
})
527565
})
528566
})

0 commit comments

Comments
 (0)