Skip to content

Commit e858ddb

Browse files
authored
test(usage): usage service tests keep their state directory until cache writes land (pingdotgg#17636)
1 parent 0caa95d commit e858ddb

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

‎apps/server/src/usage/UsageService.test.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ const layerService = (input: {
132132
Layer.provideMerge(ProviderHostLive.layer),
133133
Layer.provideMerge(Layer.mock(BackgroundPolicy.BackgroundPolicy)({})),
134134
Layer.provideMerge(Layer.mock(ServerSecretStore.ServerSecretStore)({})),
135-
Layer.provideMerge(ServerConfig.layerTest(process.cwd(), { prefix: input.prefix })),
135+
Layer.provideMerge(
136+
ServerConfig.layerTest(process.cwd(), NodePath.join(input.home, input.prefix)),
137+
),
136138
Layer.provideMerge(NodeServices.layer),
137139
Layer.provideMerge(Layer.succeed(HostProcess.Platform, input.platform ?? "linux")),
138140
Layer.provideMerge(ServerSettings.layerTest(input.settings)),
@@ -1203,8 +1205,7 @@ describe("UsageService", () => {
12031205
return text;
12041206
});
12051207

1206-
const restarted = yield* UsageService.make;
1207-
const summary = yield* restarted.readSummary(WINDOW);
1208+
const summary = yield* (yield* UsageService.make).readSummary(WINDOW);
12081209
// The live rollout re-parses at the ultrafast rate (10 x 6); the
12091210
// deleted one keeps its saved v4 usage at the standard rate (20 x 1).
12101211
assert.strictEqual(totalOutputTokens(summary), 30);
@@ -1217,9 +1218,6 @@ describe("UsageService", () => {
12171218
yield* Effect.promise(() => NodeFSP.readFile(legacyPath, "utf8")),
12181219
legacy,
12191220
);
1220-
// The migrated cache is written in the background; let it land before
1221-
// the layer removes the state directory under it.
1222-
yield* restarted.awaitPersisted;
12231221
}).pipe(
12241222
Effect.provide(
12251223
layerService({

0 commit comments

Comments
 (0)