Skip to content

[BUG] Tests overwrite user auth.json (#10371) #10370

Description

@CasualDeveloper

Problem

Running bun run --cwd packages/opencode test overwrites the user's ~/.local/share/opencode/auth.json instead of keeping writes in a test sandbox.

Reproduction

  1. Ensure ~/.local/share/opencode/auth.json has real data.
  2. Run bun run --cwd packages/opencode test.
  3. Observe auth.json replaced with test credentials.

Root Cause

packages/opencode/test/preload.ts imports Global before XDG/OPENCODE_TEST_HOME env vars are set, so xdg-basedir resolves to the real home directory.

Proposed Fix

  • Move the Global import to after the test env vars are configured so tests write into the temp XDG data directory.
  • Add a guard to fail fast if Global.Path.data isn’t under the temp test dir.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions