惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
Martin Fowler
Martin Fowler
Vercel News
Vercel News
U
Unit 42
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
Y
Y Combinator Blog
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog RSS Feed
N
Netflix TechBlog - Medium
GbyAI
GbyAI
F
Fortinet All Blogs
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
M
MIT News - Artificial intelligence
D
Docker
IT之家
IT之家
Stack Overflow Blog
Stack Overflow Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test: align fs-safe dependency expectations · openclaw/op...
steipete · 2026-05-07 · via Recent Commits to openclaw:main

@@ -52,30 +52,97 @@ describe("media store", () => {

5252

segment: string;

5353

run: (store: typeof import("./store.js"), home: string) => Promise<{ path: string }>;

5454

}) {

55-

await withTempStore(async (store, home) => {

56-

const originalWriteFile = fs.writeFile.bind(fs);

57-

let injectedEnoent = false;

58-

vi.spyOn(fs, "writeFile").mockImplementation(async (...args) => {

59-

const [filePath] = args;

60-

if (

61-

!injectedEnoent &&

62-

typeof filePath === "string" &&

63-

filePath.includes(`${path.sep}${params.segment}${path.sep}`)

64-

) {

65-

injectedEnoent = true;

66-

await fs.rm(path.dirname(filePath), { recursive: true, force: true });

67-

const err = new Error("missing dir") as NodeJS.ErrnoException;

68-

err.code = "ENOENT";

69-

throw err;

70-

}

71-

return await originalWriteFile(...args);

55+

const mockKey = `./store.js?scope=retry-pruned-write-${params.segment}-${Date.now()}-${Math.random().toString(36).slice(2)}`;

56+

let injectedEnoent = false;

57+

vi.doMock("../infra/file-store.js", async (importOriginal) => {

58+

const actual = await importOriginal<typeof import("../infra/file-store.js")>();

59+

return {

60+

...actual,

61+

fileStore: (options: Parameters<typeof actual.fileStore>[0]) => {

62+

const actualStore = actual.fileStore(options);

63+

return {

64+

...actualStore,

65+

write: async (...args: Parameters<typeof actualStore.write>) => {

66+

const [relativePath] = args;

67+

if (!injectedEnoent && relativePath.includes(`${params.segment}${path.sep}`)) {

68+

injectedEnoent = true;

69+

await fs.rm(path.dirname(actualStore.path(relativePath)), {

70+

recursive: true,

71+

force: true,

72+

});

73+

const err = new Error("missing dir") as NodeJS.ErrnoException;

74+

err.code = "ENOENT";

75+

throw err;

76+

}

77+

return await actualStore.write(...args);

78+

},

79+

};

80+

},

81+

};

82+

});

83+84+

try {

85+

const storeWithMock = await importFreshModule<typeof import("./store.js")>(

86+

import.meta.url,

87+

mockKey,

88+

);

89+

await withTempStore(async (_store, home) => {

90+

const saved = await params.run(storeWithMock, home);

91+

const savedStat = await fs.stat(saved.path);

92+

expect(injectedEnoent).toBe(true);

93+

expect(savedStat.isFile()).toBe(true);

7294

});

95+

} finally {

96+

vi.doUnmock("../infra/file-store.js");

97+

}

98+

}

739974-

const saved = await params.run(store, home);

75-

const savedStat = await fs.stat(saved.path);

76-

expect(injectedEnoent).toBe(true);

77-

expect(savedStat.isFile()).toBe(true);

100+

async function expectFailedBufferWriteCase() {

101+

const mockKey = `./store.js?scope=failed-buffer-write-${Date.now()}-${Math.random().toString(36).slice(2)}`;

102+

const attemptedRelPaths: string[] = [];

103+

vi.doMock("../infra/file-store.js", async (importOriginal) => {

104+

const actual = await importOriginal<typeof import("../infra/file-store.js")>();

105+

return {

106+

...actual,

107+

fileStore: (options: Parameters<typeof actual.fileStore>[0]) => {

108+

const actualStore = actual.fileStore(options);

109+

return {

110+

...actualStore,

111+

write: async (...args: Parameters<typeof actualStore.write>) => {

112+

const [relativePath] = args;

113+

if (relativePath.includes(`failed-buffer${path.sep}`)) {

114+

attemptedRelPaths.push(relativePath);

115+

const err = new Error("no space left on device") as NodeJS.ErrnoException;

116+

err.code = "ENOSPC";

117+

throw err;

118+

}

119+

return await actualStore.write(...args);

120+

},

121+

};

122+

},

123+

};

78124

});

125+126+

try {

127+

const storeWithMock = await importFreshModule<typeof import("./store.js")>(

128+

import.meta.url,

129+

mockKey,

130+

);

131+

await withTempStore(async (_store) => {

132+

const mediaDir = await storeWithMock.ensureMediaDir();

133+

await expect(

134+

storeWithMock.saveMediaBuffer(Buffer.from("voice"), "audio/ogg", "failed-buffer"),

135+

).rejects.toMatchObject({ code: "ENOSPC" });

136+137+

const failedDir = path.join(mediaDir, "failed-buffer");

138+

const entries = await fs.readdir(failedDir).catch(() => []);

139+

expect(attemptedRelPaths).toHaveLength(1);

140+

expect(path.basename(attemptedRelPaths[0] ?? "")).toMatch(/^[^/\\]+\.ogg$/);

141+

expect(entries).toEqual([]);

142+

});

143+

} finally {

144+

vi.doUnmock("../infra/file-store.js");

145+

}

79146

}

8014781148

async function expectSavedOriginalFilenameCase(params: {

@@ -310,35 +377,7 @@ describe("media store", () => {

310377

{

311378

name: "does not leave final media artifacts when buffer writes fail",

312379

run: async () => {

313-

await withTempStore(async (store) => {

314-

const mediaDir = await store.ensureMediaDir();

315-

const originalWriteFile = fs.writeFile.bind(fs);

316-

const attemptedPaths: string[] = [];

317-

vi.spyOn(fs, "writeFile").mockImplementation(async (...args) => {

318-

const [filePath] = args;

319-

if (

320-

typeof filePath === "string" &&

321-

filePath.includes(`${path.sep}failed-buffer${path.sep}`)

322-

) {

323-

attemptedPaths.push(filePath);

324-

await originalWriteFile(filePath, Buffer.alloc(0), args[2]);

325-

const err = new Error("no space left on device") as NodeJS.ErrnoException;

326-

err.code = "ENOSPC";

327-

throw err;

328-

}

329-

return await originalWriteFile(...args);

330-

});

331-332-

await expect(

333-

store.saveMediaBuffer(Buffer.from("voice"), "audio/ogg", "failed-buffer"),

334-

).rejects.toMatchObject({ code: "ENOSPC" });

335-336-

const failedDir = path.join(mediaDir, "failed-buffer");

337-

const entries = await fs.readdir(failedDir).catch(() => []);

338-

expect(attemptedPaths).toHaveLength(1);

339-

expect(path.basename(attemptedPaths[0] ?? "")).toMatch(/^\..+\.tmp$/);

340-

expect(entries).toEqual([]);

341-

});

380+

await expectFailedBufferWriteCase();

342381

},

343382

},

344383

{