test: give e2e-real-dbt-5 its own HOME

RA
2d ago
+49-22

Issue for this PR

Closes #1858

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

e2e-real-dbt-5.test.ts ran altimate-dbt init with the developer's real HOME, so a local run pointed their dbt.json in ~/.altimate-code at the test's temp project, which the test then deletes.

setupProject now sets HOME to a home folder inside the test project, and teardown puts it back if it was changed. The validators already pass env: process.env when they spawn altimate-dbt. The test's own init and build calls didn't, and Bun's spawnSync without env uses the environment the process started with, so they now go through an altimateDbt helper that passes it.

A new test runs init and checks the config landed in the test's home.

How did you verify your code works?

I ran only this file, never the whole test/altimate/ tree.

  • Main's test code plus only the new test, with HOME set to a scratch folder: the new test fails, and the scratch folder gets a dbt.json pointing at a deleted /tmp/e2e-real-5-* project.
  • This branch, same scratch HOME: 4 pass, 17 skip, nothing written there. Setting HOME without the env change still fails the new test.
  • This branch with the real HOME: 4 pass, and there's no dbt.json in ~/.altimate-code before or after.
  • bun run typecheck in packages/opencode, and the marker guard.

Cost side effects

None. Test-only.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"

Codex review log: https://github.com/AltimateAI/altimate-code/pull/1859#issuecomment-7256805621

🤖 Generated with Claude Code

https://claude.ai/code/session_01BXxzvsr1G2qqFbMCyPZg3G


Summary by cubic

Fixes e2e-real-dbt-5.test.ts writing altimate-dbt init config to the developer's real ~/.altimate-code/dbt.json, which a local run would then point at a deleted temp project.

  • setupProject() now sets HOME to a home folder inside the test project and restores it in teardown(), but only when setupProject() actually changed it — a test that sets dir itself bypasses it and no longer risks clobbering HOME for the run.
  • Test spawns go through a new altimateDbt() helper that passes env: process.env, since Bun's spawnSync otherwise uses the startup environment.
  • Adds a test verifying init writes its config under the test's home.

Summary by CodeRabbit

  • Tests
    • Updated end-to-end test setup to use an isolated home directory within the temporary project, restoring the original environment when needed.
    • Added coverage confirming initialization writes its configuration to the isolated home directory.
    • Updated validator test commands to run with the project’s environment and working directory, improving consistency across test scenarios.