Skip to content

[#101] Add test coverage for LockfileOperations#240

Merged
bguidolim merged 2 commits intomainfrom
feature/101-lockfile-operations-tests
Mar 6, 2026
Merged

[#101] Add test coverage for LockfileOperations#240
bguidolim merged 2 commits intomainfrom
feature/101-lockfile-operations-tests

Conversation

@bguidolim
Copy link
Owner

Summary

Adds 16 unit tests for LockfileOperations.swift, which previously had zero test coverage. Covers security-critical SHA validation, path containment, and the filesystem-based writeLockfile flow.

Closes #101

Changes

  • New Tests/MCSTests/LockfileOperationsTests.swift with 16 tests across three methods:
    • writeLockfile(at:) — 4 tests: basic generation, pack filtering, no-op on empty state, overwrite with drift
    • checkoutLockedCommits(at:) — 11 tests: missing lockfile, SHA regex boundaries (7-char min, 64-char max, uppercase rejection, 5 flag injection payloads), local pack skipping, path traversal rejection, missing pack directory, mixed pack failure
    • updatePacks() — 1 test: early return on empty registry

Test plan

  • swift test passes locally
  • swiftformat --lint . and swiftlint pass without violations

- 16 tests covering writeLockfile, checkoutLockedCommits guard paths, and updatePacks early return
- SHA validation regex edge cases: boundary lengths, uppercase rejection, flag injection payloads
- Path containment, missing lockfile, missing pack directory, and local pack skip scenarios
@bguidolim bguidolim force-pushed the feature/101-lockfile-operations-tests branch from 23d29d0 to f324df2 Compare March 6, 2026 08:05
- New Git section enforcing separate commits and regular push only
@bguidolim bguidolim merged commit af41e34 into main Mar 6, 2026
4 checks passed
@bguidolim bguidolim deleted the feature/101-lockfile-operations-tests branch March 6, 2026 08:10
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.

M2: LockfileOperations.swift (174 lines) has zero test coverage

1 participant