Skip to content

fix(config): tests delete real ~/.asana-cli; make config dir overridable #51

Description

@amondnet

Problem

The CLI's config directory is hardcoded to the real user home dir with no override, and the unit tests delete it. Running bun test destroys the developer's real Asana credentials.

Evidence

  • src/lib/config.ts:6const CONFIG_DIR = join(homedir(), '.asana-cli') — no environment override; always points at the real home directory.
  • test/lib/asana-client.test.ts:8const TEST_CONFIG_DIR = join(homedir(), '.asana-cli')
  • test/lib/asana-client.test.ts:18,29rmSync(TEST_CONFIG_DIR, { recursive: true, force: true }) in beforeEach/afterEach.

So the "test" config dir is the real config dir. Any bun test run wipes ~/.asana-cli/config.json, forcing the developer to re-authenticate (asana auth login). This was observed in practice while working on #43/#44/#45.

Impact

  • Destroys real user/developer credentials on every local test run.
  • Fragile in CI if $HOME is shared or persisted.
  • Tests are not isolated (violates FIRST principles in dev-docs/TESTING.md).

Proposed fix

  1. Make the config directory overridable, e.g. honor ASANA_CONFIG_DIR (fall back to join(homedir(), '.asana-cli')).
    • src/lib/config.ts: resolve CONFIG_DIR/CONFIG_FILE from process.env.ASANA_CONFIG_DIR ?? join(homedir(), '.asana-cli').
  2. Point the tests at an isolated temp dir instead of the real home:
    • test/lib/asana-client.test.ts: set ASANA_CONFIG_DIR (or HOME) to mkdtempSync(...) in setup, and only rmSync that temp dir.
  3. Add a guard/regression test asserting the resolved config dir is not the real home when the override is set.

Acceptance criteria

  • bun test never reads or deletes the real ~/.asana-cli.
  • ASANA_CONFIG_DIR (documented in skills/asana-cli/references/commands.md env-vars section) overrides the config location.
  • Regression test covers the override path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions