Skip to content

test(#1141): no hardcoded absent-path fixture; state-hook error test has no FS side effect - #1158

Merged
admarble merged 6 commits into
mainfrom
feature/1141-test-state-hook-test-ts-writes-a-real-nonexistent-
Sep 25, 2026
Merged

admarble merged 6 commits into
mainfrom
feature/1141-test-state-hook-test-ts-writes-a-real-nonexistent-

Conversation

@admarble

@admarble admarble commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • state-hook.test.ts error-path test now uses a tmp-relative absent path with fs.mkdirSync stubbed (partial vi.mock("fs"), since the ESM namespace isn't spy-able) and asserts nothing was created.
  • The 5 remaining hardcoded absent-path sites (state-utils, status, merge-check-extended, behavior-rule-detector x2) use path.join(os.tmpdir(), ...). The last two sites, __tests__/relay-cli.test.ts and __tests__/pre-tool-hook.integration.test.ts, were converted in 1f0aa8c. The issue's count of seven files was right.
  • New gate src/lib/no-nonexistent-path-gate.test.ts (literal assembled at runtime).

Pre-PR AC Verification

AC Status Evidence
AC-1 ✅ state-hook.test.ts "should not throw on state errors"
AC-2 ✅ grep -rn "/nonexistent/path" src __tests__ empty
AC-3 ✅ gate + mutation below

Build, lint, full npm test (338 files, 8380 passed) green. No production change.

Mutation-verified: AC-3 — appended literal to scripts/analytics/gap-signal.test.ts (and earlier to tests/relay-cli.test.ts); src/lib/no-nonexistent-path-gate.test.ts failed; restored.

Closes #1141

🤖 Generated with Claude Code

@admarble
admarble merged commit 8d76da8 into main Sep 25, 2026
7 checks passed
@admarble
admarble deleted the feature/1141-test-state-hook-test-ts-writes-a-real-nonexistent- branch September 25, 2026 12:31
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.

test: state-hook.test.ts writes a real /nonexistent/path/state.json when run as root, poisoning state-utils.test.ts

1 participant