Skip to content

test: add findRepoRoot and findDbPath ceiling boundary tests#475

Merged
carlos-alm merged 3 commits intomainfrom
fix/db-ceiling-tests
Mar 17, 2026
Merged

test: add findRepoRoot and findDbPath ceiling boundary tests#475
carlos-alm merged 3 commits intomainfrom
fix/db-ceiling-tests

Conversation

@carlos-alm
Copy link
Contributor

Summary

  • Add findRepoRoot unit tests: git toplevel resolution, non-git fallback, caching behavior, explicit dir bypass
  • Add findDbPath ceiling boundary tests: stops at git ceiling (doesn't escape worktree), finds DB within boundary, graceful non-git fallback
  • Strengthen existing findDbPath tests with _resetRepoRootCache calls and mock isolation

Split out from #473 (docs PR) where these test changes were out of scope.

Test plan

  • All 24 db.test.js tests pass
  • Lint clean

@claude
Copy link

claude bot commented Mar 17, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 17, 2026

Greptile Summary

This PR makes a single comment-only change inside tests/unit/db.test.js: the finds DB within the ceiling boundary test's two terse inline comments are replaced with a three-line block comment that explains the exact reason exact path comparison is avoided (Windows CI 8.3 short-name resolution discrepancy between realpathSync and git's output). No assertions, test logic, or cleanup code are altered.

  • The surrounding test suite — findRepoRoot unit tests and findDbPath ceiling boundary tests — is already in place in the base branch and is not modified by this commit.
  • The beforeEach/afterEach _resetRepoRootCache guards, execFileSyncSpy isolation, and try/finally process.cwd restoration patterns used throughout the file are all sound.
  • The clarified comment accurately matches the implementation: findDbPath and findRepoRoot both call realpathSync internally, and outerDir is also realpathSync-resolved in beforeAll, so path.basename(outerDir) gives a stable suffix regardless of whether 8.3 short names are in play — making the not.toContain check the correct alternative to a brittle toBe equality.

Confidence Score: 5/5

  • This PR is safe to merge — it is a comment-only change with no impact on test logic or production code.
  • The single commit modifies only two inline comments, replacing them with a more precise explanation. All assertions, cleanup code, and test structure are untouched. The comment accurately reflects the implementation's behavior around Windows 8.3 short-name resolution.
  • No files require special attention.

Important Files Changed

Filename Overview
tests/unit/db.test.js Comment-only change: two vague inline comments in finds DB within the ceiling boundary are replaced with a single precise block comment explaining why exact path comparison is avoided (Windows 8.3 short names on CI). No assertion logic, test structure, or cleanup paths were altered.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["finds DB within the ceiling boundary<br/>(test)"] --> B["mkdirSync worktreeRoot/.codegraph"]
    B --> C["writeFileSync .../graph.db (empty)"]
    C --> D["mock process.cwd → innerDir"]
    D --> E["_resetRepoRootCache()"]
    E --> F["findDbPath()"]
    F --> G["findRepoRoot() → ceiling = worktreeRoot<br/>(via git rev-parse + realpathSync)"]
    G --> H{"walk up from innerDir"}
    H -->|"found worktreeRoot/.codegraph/graph.db"| I["return candidate path"]
    I --> J["expect fs.existsSync(result) → true"]
    J --> K["expect result matches /\\.codegraph[/\\\\]graph\\.db$/"]
    K --> L["expect result NOT to contain<br/>basename(outerDir) + sep + .codegraph"]
    L --> M["finally: restore process.cwd<br/>rmSync worktreeRoot/.codegraph"]
Loading

Last reviewed commit: ef09f9f

@carlos-alm carlos-alm merged commit 2607ec6 into main Mar 17, 2026
14 checks passed
@carlos-alm carlos-alm deleted the fix/db-ceiling-tests branch March 17, 2026 01:40
@github-actions github-actions bot locked and limited conversation to collaborators Mar 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant