Skip to content

M10: Tests for safety-critical error branches (8 subsystems) (closes #30) - #48

Merged
curtyo18 merged 1 commit into
mainfrom
issue/M10-error-branch-tests
May 17, 2026
Merged

M10: Tests for safety-critical error branches (8 subsystems) (closes #30)#48
curtyo18 merged 1 commit into
mainfrom
issue/M10-error-branch-tests

Conversation

@curtyo18

Copy link
Copy Markdown
Owner

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.).

  • catalog/migrateMIGRATION_FAILED (db.exec spy) and MIGRATION_FK_VIOLATIONS (orphan FK row), confirming foreign_keys is re-enabled in finally in both cases
  • dedupe/applierFILE_MISSING guard: file in catalog but deleted from disk → failed=1, typed error message (not raw ENOENT)
  • dedupe/scorer — zero-copy throw + single-copy 'only copy' branch
  • quarantineQUARANTINE_COLLISION, QUARANTINE_NOT_FOUND, QUARANTINE_FILE_MISSING typed errors with correct .code
  • catalog/locatordefaultPointerPath/defaultCatalogPath with APPDATA set vs unset (env restored in afterEach)
  • drives/volumedetectWindows 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 the full execFileAsync → parseMediainfoOutput pipeline
  • catalog/batches-repoupdateOperationStatus with all optional fields (postHash, errorMessage, destPath); raw DB columns verified plus the OperationRecord mapping

Test plan

  • All 8 clusters have at least the tests listed in the issue body
  • Existing tests still pass: 296 engine baseline → 310; UI 21 unchanged; shared 8 unchanged
  • Lint clean (npm run lint exits 0)
  • Typecheck clean (npm run typecheck exits 0)
  • No production code changes

Deviations

None. The volume.ts happy-path test revealed that detectWindows produces no structured warning log when execFileSync fails (it silently catches and falls back). The test verifies the fallback behavior is correct; the missing log is documented as a code comment in volume.test.ts but was not treated as a bug requiring a production fix — the fallback itself is safe.

Out of scope

  • Full UI route test coverage (M8 added some; broader coverage is a separate issue)
  • CLI formatStatus/formatBytes tests (Minor finding)
  • reverseCompletedViaExisting (covered in M7)

Closes #30

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>
@curtyo18
curtyo18 merged commit fb49245 into main May 17, 2026
2 checks passed
@curtyo18
curtyo18 deleted the issue/M10-error-branch-tests branch May 17, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

M10: [Major] Add tests for safety-critical error branches (8 subsystems)

1 participant