Skip to content

Commit 178ba31

Browse files
committed
revert test/model-based/helpers.ts to main's version
Remove dead fallback code for missing SENTRY_CONFIG_DIR (preload.ts always sets it) and the 'delete process.env' pattern that violates AGENTS.md rules.
1 parent a2cb5f8 commit 178ba31

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

test/model-based/helpers.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,19 @@
55
*/
66

77
import { mkdirSync } from "node:fs";
8-
import { homedir } from "node:os";
98
import { join } from "node:path";
109
import { CONFIG_DIR_ENV_VAR, closeDatabase } from "../../src/lib/db/index.js";
1110

1211
/**
1312
* Create an isolated database context for model-based tests.
1413
* Each test run gets its own SQLite database to avoid interference.
1514
*
16-
* Falls back to creating a temp directory if CONFIG_DIR_ENV_VAR is not set,
17-
* which can happen due to test ordering/worker isolation in CI.
18-
*
1915
* @returns Cleanup function to call after test completes
2016
*/
2117
export function createIsolatedDbContext(): () => void {
22-
const originalEnvValue = process.env[CONFIG_DIR_ENV_VAR];
23-
24-
let testBaseDir = originalEnvValue;
18+
const testBaseDir = process.env[CONFIG_DIR_ENV_VAR];
2519
if (!testBaseDir) {
26-
// Fallback: create a temp base dir (matches preload.ts pattern)
27-
testBaseDir = join(homedir(), `.sentry-cli-test-model-${process.pid}`);
28-
mkdirSync(testBaseDir, { recursive: true });
29-
process.env[CONFIG_DIR_ENV_VAR] = testBaseDir;
20+
throw new Error(`${CONFIG_DIR_ENV_VAR} not set - run tests via bun test`);
3021
}
3122

3223
// Close any existing database connection
@@ -42,12 +33,8 @@ export function createIsolatedDbContext(): () => void {
4233

4334
return () => {
4435
closeDatabase();
45-
// Restore the original env var value, preserving undefined if it was unset
46-
if (originalEnvValue === undefined) {
47-
delete process.env[CONFIG_DIR_ENV_VAR];
48-
} else {
49-
process.env[CONFIG_DIR_ENV_VAR] = originalEnvValue;
50-
}
36+
// Restore original base dir for next test
37+
process.env[CONFIG_DIR_ENV_VAR] = testBaseDir;
5138
};
5239
}
5340

0 commit comments

Comments
 (0)