fix(test): reset _productionMode in getDefaultDbPath test
Bun runs all test files in a single process, so module-level state leaks between files. The getDefaultDbPath test now resets the _productionMode flag before asserting it throws, fixing the flaky failure on Bun (ubuntu-latest) in CI.
This commit is contained in:
parent
32e504c883
commit
66e70c028e
@ -522,6 +522,11 @@ export function enableProductionMode(): void {
|
|||||||
_productionMode = true;
|
_productionMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Reset production mode flag — only for testing. */
|
||||||
|
export function _resetProductionModeForTesting(): void {
|
||||||
|
_productionMode = false;
|
||||||
|
}
|
||||||
|
|
||||||
export function getDefaultDbPath(indexName: string = "index"): string {
|
export function getDefaultDbPath(indexName: string = "index"): string {
|
||||||
// Always allow override via INDEX_PATH (for testing)
|
// Always allow override via INDEX_PATH (for testing)
|
||||||
if (process.env.INDEX_PATH) {
|
if (process.env.INDEX_PATH) {
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import {
|
|||||||
homedir,
|
homedir,
|
||||||
resolve,
|
resolve,
|
||||||
getDefaultDbPath,
|
getDefaultDbPath,
|
||||||
|
_resetProductionModeForTesting,
|
||||||
getPwd,
|
getPwd,
|
||||||
getRealPath,
|
getRealPath,
|
||||||
isVirtualPath,
|
isVirtualPath,
|
||||||
@ -48,6 +49,9 @@ describe("Path Utilities", () => {
|
|||||||
test("getDefaultDbPath throws in test mode without INDEX_PATH", () => {
|
test("getDefaultDbPath throws in test mode without INDEX_PATH", () => {
|
||||||
const originalIndexPath = process.env.INDEX_PATH;
|
const originalIndexPath = process.env.INDEX_PATH;
|
||||||
delete process.env.INDEX_PATH;
|
delete process.env.INDEX_PATH;
|
||||||
|
// Reset production mode in case another test file set it (bun runs all
|
||||||
|
// files in a single process, so module state leaks between files).
|
||||||
|
_resetProductionModeForTesting();
|
||||||
|
|
||||||
expect(() => getDefaultDbPath()).toThrow("Database path not set");
|
expect(() => getDefaultDbPath()).toThrow("Database path not set");
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user