M10: Tests for safety-critical error branches (8 subsystems) (closes #30) - #48
Merged
Conversation
Pure test additions. No production code changes. Adds coverage for the error paths that guard against silent data corruption — paths whose absence in the suite was the M10 finding from the 2026-05-17 quality review: - catalog/migrate: MIGRATION_FAILED (db.exec spy) and MIGRATION_FK_VIOLATIONS (orphan FK row), including foreign_keys pragma re-enabled in finally in both cases - dedupe/applier: FILE_MISSING guard (file in catalog, gone from disk) — verifies failed=1 and error_message is typed, not ENOENT - dedupe/scorer: zero-copy throw + single-copy "only copy" branch - quarantine: COLLISION, NOT_FOUND, FILE_MISSING typed errors all carrying QuarantineError with the correct .code - catalog/locator: defaultPointerPath/defaultCatalogPath with APPDATA set vs unset (env restored in afterEach) - drives/volume: detectWindows happy path (execFileSync mocked via vi.mock + resolve spy for Linux CI) + subprocess-failure fallback to synthSerial - scan/metadata-video: happy path via a real shell-script stub binary that prints canned MediaInfo JSON; exercises full execFileAsync → parseMediainfoOutput pipeline - catalog/batches-repo: updateOperationStatus with postHash, errorMessage, and destPath all set; raw DB columns verified plus the OperationRecord mapping Engine test count: 296 baseline → 310 (+14). UI tests unchanged (21). Lint and typecheck clean. Closes #30 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pure test additions covering safety-critical error branches across 8 subsystems. No production code changes.
Each branch in scope is the primary defense against silent data corruption in its area. They were uncovered at review baseline; this PR catches future regressions in the error paths themselves (wrong error code, mis-incremented counter, SQL column typo, etc.).
MIGRATION_FAILED(db.exec spy) andMIGRATION_FK_VIOLATIONS(orphan FK row), confirmingforeign_keysis re-enabled infinallyin both casesFILE_MISSINGguard: file in catalog but deleted from disk →failed=1, typed error message (not raw ENOENT)'only copy'branchQUARANTINE_COLLISION,QUARANTINE_NOT_FOUND,QUARANTINE_FILE_MISSINGtyped errors with correct.codedefaultPointerPath/defaultCatalogPathwithAPPDATAset vs unset (env restored inafterEach)detectWindowshappy path (execFileSync mocked viavi.mock+resolvespy for Linux CI) + subprocess-failure fallback tosynthSerialexecFileAsync → parseMediainfoOutputpipelineupdateOperationStatuswith all optional fields (postHash,errorMessage,destPath); raw DB columns verified plus theOperationRecordmappingTest plan
npm run lintexits 0)npm run typecheckexits 0)Deviations
None. The volume.ts happy-path test revealed that
detectWindowsproduces no structured warning log whenexecFileSyncfails (it silently catches and falls back). The test verifies the fallback behavior is correct; the missing log is documented as a code comment involume.test.tsbut was not treated as a bug requiring a production fix — the fallback itself is safe.Out of scope
formatStatus/formatBytestests (Minor finding)reverseCompletedViaExisting(covered in M7)Closes #30