refactor: share embedding batch retry helper

This commit is contained in:
Peter Steinberger 2026-03-13 20:16:42 +00:00
parent 1a5a3fecf3
commit 95818a7c32
1 changed files with 13 additions and 12 deletions

View File

@ -28,6 +28,17 @@ const fx = installEmbeddingManagerFixture({
const { embedBatch } = fx;
describe("memory embedding batches", () => {
async function expectSyncWithFastTimeouts(manager: {
sync: (params: { reason: string }) => Promise<void>;
}) {
const restoreFastTimeouts = useFastShortTimeouts();
try {
await manager.sync({ reason: "test" });
} finally {
restoreFastTimeouts();
}
}
it("splits large files across multiple embedding batches", async () => {
const memoryDir = fx.getMemoryDir();
const managerLarge = fx.getManagerLarge();
@ -93,12 +104,7 @@ describe("memory embedding batches", () => {
return texts.map(() => [0, 1, 0]);
});
const restoreFastTimeouts = useFastShortTimeouts();
try {
await managerSmall.sync({ reason: "test" });
} finally {
restoreFastTimeouts();
}
await expectSyncWithFastTimeouts(managerSmall);
expect(calls).toBe(3);
}, 10000);
@ -119,12 +125,7 @@ describe("memory embedding batches", () => {
return texts.map(() => [0, 1, 0]);
});
const restoreFastTimeouts = useFastShortTimeouts();
try {
await managerSmall.sync({ reason: "test" });
} finally {
restoreFastTimeouts();
}
await expectSyncWithFastTimeouts(managerSmall);
expect(calls).toBe(2);
}, 10000);