























@@ -265,26 +265,31 @@ describe("buildFileEntry", () => {
265265expect(built?.structuredInputBytes).toBeGreaterThan(0);
266266});
267267268-it("skips lazy multimodal indexing when the file grows after discovery", async () => {
269-const tmpDir = getTmpDir();
270-const target = path.join(tmpDir, "diagram.png");
271-await fs.writeFile(target, Buffer.from("png"));
272-273-const entry = await buildFileEntry(target, tmpDir, multimodal);
274-await fs.writeFile(target, Buffer.alloc(entry!.size + 32, 1));
275-276-await expect(buildMultimodalChunkForIndexing(entry!)).resolves.toBeNull();
277-});
278-279-it("skips lazy multimodal indexing when file bytes change after discovery", async () => {
280-const tmpDir = getTmpDir();
281-const target = path.join(tmpDir, "diagram.png");
282-await fs.writeFile(target, Buffer.from("png"));
283-284-const entry = await buildFileEntry(target, tmpDir, multimodal);
285-await fs.writeFile(target, Buffer.from("gif"));
286-287-await expect(buildMultimodalChunkForIndexing(entry!)).resolves.toBeNull();
268+it("skips lazy multimodal indexing when file state changes after discovery", async () => {
269+for (const testCase of [
270+{
271+name: "grows",
272+mutate: async (target: string, entrySize: number) => {
273+await fs.writeFile(target, Buffer.alloc(entrySize + 32, 1));
274+},
275+},
276+{
277+name: "bytes change",
278+mutate: async (target: string) => {
279+await fs.writeFile(target, Buffer.from("gif"));
280+},
281+},
282+] as const) {
283+const tmpDir = getTmpDir();
284+const target = path.join(tmpDir, `${testCase.name}.png`);
285+await fs.writeFile(target, Buffer.from("png"));
286+287+const entry = await buildFileEntry(target, tmpDir, multimodal);
288+expect(entry, testCase.name).not.toBeNull();
289+await testCase.mutate(target, entry!.size);
290+291+await expect(buildMultimodalChunkForIndexing(entry!), testCase.name).resolves.toBeNull();
292+}
288293});
289294});
290295此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。