Uh oh!
There was an error while loading. Please reload this page.
fix(tests): prevent tests from overwriting user auth.json - Issue #10370 - #10389
fix(tests): prevent tests from overwriting user auth.json - Issue #10370#10389Luckybalabala wants to merge 1 commit into
Conversation
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
ariane-emory
commented
Jan 24, 2026
Changes in |
26cc5a9 to
703ca0eCompareLuckybalabala
commented
Jan 24, 2026
@ariane-emory You're absolutely rightThe PR included some out-of-scope changes that have now been removed. What happenedThe branch accidentally included commits from two different fixes:
Changes madeI've cleaned up the PR to only include the core fix:
The PR now focuses solely on preventing tests from overwriting the user's real ContextThe two fixes were developed around the same time and got mixed together. The UTF-8 encoding fixes (#10381) address Windows compatibility issues, while this PR (#10389) addresses test isolation concerns. Thanks for catching this—reviewers like you help keep PRs focused and maintainable! 🙏 |
703ca0e to
70e5b01Compare…malyco#10370 - Move Global import to after XDG env vars are set - Fixes critical bug where tests overwrote ~/.local/share/opencode/auth.json - xdg-basedir reads env vars at module import time - Tests now properly isolated in temp directory Root cause: Global was imported before XDG_DATA_HOME and related env vars were set, causing paths to resolve to real user home directory. This fix ensures all test data is written to the temp test directory instead of the user's actual OpenCode data directory.
70e5b01 to
0745806Compare
Summary
Fixes#10370 - Tests were overwriting the user's real auth.json file during execution.
Root Cause
The Global object was imported at the top of
test/preload.tsbefore XDG environment variables were set. Sincexdg-basedirreads environment variables at import time, this caused tests to resolve to the user's actual home directory instead of the test directory.Changes
File: test/preload.ts
Globalimport to execute AFTER allXDG_*environment variables are setxdg-basedirresolves to the test directory instead of the real home directoryBefore:
After:
Impact
npm testwould overwrite~/.local/share/opencode/auth.jsonwith test data/tmp/opencode-test-data-<pid>/homeTesting
Checklist