Skip to content

test: make safe-teardown suite hermetic like the other suites - #122

Merged
KochC merged 1 commit into
mainfrom
test/hermetic-safe-teardown
Nov 11, 2026
Merged

KochC merged 1 commit into
mainfrom
test/hermetic-safe-teardown

Conversation

@KochC

@KochC KochC commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Problem

test/safe-teardown.test.js was the only test suite that did not scrub OPENCODE_LLM_PROXY_* variables from the environment before each test.

With a developer or CI shell that exports a token (OPENCODE_LLM_PROXY_TOKEN), every request in the suite got a 401, so seven tests failed for reasons unrelated to the code under test:

not ok 163 - non-streaming success deletes the throwaway session
not ok 164 - non-streaming client abort does NOT delete the session (FOREIGN KEY race)
not ok 165 - keepSessions=true never deletes, even on success
not ok 170 - hung session.delete does not block the response past the delete timeout
not ok 171 - streaming success still deletes the throwaway session
not ok 172 - streaming client abort does NOT delete the session (FOREIGN KEY race)
not ok 173 - streaming session.error does NOT delete the session

Fix

Add the same beforeEach scrub already used by index.test.js, test/http-integration.test.js, test/stream-conformance.test.js, and test/tool-payload-fidelity.test.js.

The two tests that need specific values (OPENCODE_LLM_PROXY_KEEP_SESSIONS, OPENCODE_LLM_PROXY_DELETE_TIMEOUT_MS) set them inside their own bodies, i.e. after the hook runs, so they are unaffected.

Verification

  • npm test with a token exported in the shell: 326 tests, 326 pass, 0 fail (previously 7 fail, 319 pass).
  • npm run lint clean.
  • No production code changed.

test/safe-teardown.test.js was the only suite that did not scrub
OPENCODE_LLM_PROXY_* variables from the environment before each test.
With a developer/CI shell that exports a token (OPENCODE_LLM_PROXY_TOKEN)
every request in the suite got a 401, so seven tests failed for reasons
unrelated to the code under test.

Add the same beforeEach scrub used by stream-conformance, http-integration
and tool-payload-fidelity. The two tests that need specific values still set
them inside their own bodies, i.e. after the hook runs.
@KochC
KochC merged commit e75f365 into main Nov 11, 2026
4 checks passed
@KochC
KochC deleted the test/hermetic-safe-teardown branch November 11, 2026 00:53
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