Skip to content

test: add 38 unit tests for lib/git.ts and lib/files.ts#203

Open
TerminalGravity wants to merge 3 commits intomainfrom
test/git-lib-coverage-v2
Open

test: add 38 unit tests for lib/git.ts and lib/files.ts#203
TerminalGravity wants to merge 3 commits intomainfrom
test/git-lib-coverage-v2

Conversation

@TerminalGravity
Copy link
Collaborator

@TerminalGravity TerminalGravity commented Mar 10, 2026

Adds test coverage for two core untested lib modules.

lib/git.ts (26 tests)

  • run(): array/string args, output trimming, custom/default timeouts
  • Error handling: timeout/killed, SIGTERM, stderr, stdout fallback, ENOENT, generic failure
  • All convenience functions: getBranch, getStatus, getRecentCommits, getLastCommit, getLastCommitTime, getStagedFiles
  • Fallback logic: getDiffFiles (HEAD3 → HEAD1 → 'no commits'), getDiffStat (HEAD5 → HEAD3 → fallback)

lib/files.ts (12 tests)

  • readIfExists: missing files, text reading, line limits, binary rejection (null bytes)
  • findWorkspaceDocs: return shape, metadataOnly mode, 40-line content cap
  • PROJECT_DIR: export validation

Test count: 43 → 81 (all green)

- examples/.preflight/config.yml — profile, related projects, thresholds, embeddings
- examples/.preflight/triage.yml — keyword rules and strictness tuning
- examples/.preflight/contracts/api.yml — manual cross-service contract definitions
- examples/README.md — quick setup instructions
- README.md — link to examples from config reference section
Covers run() with array/string args, timeout handling, error paths
(ENOENT, stderr, SIGTERM, killed), plus all convenience functions
(getBranch, getStatus, getDiffFiles fallback logic, getDiffStat, etc.)

Increases test count from 43 to 69.
Tests readIfExists (null handling, line limits, binary rejection)
and findWorkspaceDocs (return shape, metadataOnly, 40-line cap).

Total test count: 43 → 81.
@TerminalGravity TerminalGravity changed the title test: add 26 unit tests for lib/git.ts test: add 38 unit tests for lib/git.ts and lib/files.ts Mar 10, 2026
Copy link
Collaborator Author

@TerminalGravity TerminalGravity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look comprehensive — good coverage on run() edge cases (timeout, SIGTERM, stderr fallback) and the getDiffFiles/getDiffStat fallback chains.

One thing: this PR also includes the examples/.preflight/ directory and README changes that belong in #201. Can you rebase to drop those files and keep this test-only?

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.

1 participant