Skip to content

Commit 5f96fdb

Browse files
committed
Reset the pricing refresh latch before each test, not just after
schedulePricingMetadataRefresh guards itself with a module-level one-shot flag shared by the whole test process. Any other file that exercises loadConfig's real bootstrap path leaves that flag set to true and never clears it, so this file's own first test silently inherited "already scheduled" from whichever file ran before it and its offlineFetch was never called.
1 parent 376ab20 commit 5f96fdb

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/pricing-metadata.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { afterEach, describe, expect, test } from "bun:test";
1+
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
22
import { mkdtemp, rm } from "node:fs/promises";
33
import { tmpdir } from "node:os";
44
import { join } from "node:path";
@@ -15,6 +15,14 @@ import { contextWindowFor } from "./provider/context-window.js";
1515
import { writePricingCache } from "./cost/pricing-fetcher.js";
1616

1717
describe("pricing-metadata", () => {
18+
// refreshScheduled is a module-level one-shot latch shared with every other
19+
// file in this process; another file's real loadConfig() call can leave it
20+
// set before this file's first test ever runs. Reset on both sides so this
21+
// suite's outcome does not depend on what ran before it.
22+
beforeEach(() => {
23+
resetPricingMetadataRefreshForTests();
24+
});
25+
1826
afterEach(() => {
1927
resetPricingMetadataRefreshForTests();
2028
applyPricingCacheMetadata(null);

0 commit comments

Comments
 (0)