test: tighten extension cleanup assertions · openclaw/openclaw@20a2ac3
shakkernerd
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -9,6 +9,10 @@ function escapeRegExp(value: string): string {
|
9 | 9 | return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); |
10 | 10 | } |
11 | 11 | |
| 12 | +async function expectPathMissing(targetPath: string): Promise<void> { |
| 13 | +await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" }); |
| 14 | +} |
| 15 | + |
12 | 16 | const hoisted = vi.hoisted(() => { |
13 | 17 | const sessionStore: Record<string, Record<string, unknown>> = { |
14 | 18 | "agent:main:main": { |
@@ -2316,7 +2320,7 @@ describe("active-memory plugin", () => {
|
2316 | 2320 | prependContext: expect.stringContaining("temporary partial recall summary"), |
2317 | 2321 | }); |
2318 | 2322 | await vi.waitFor(async () => { |
2319 | | -await expect(fs.access(tempSessionFile)).rejects.toThrow(); |
| 2323 | +await expectPathMissing(tempSessionFile); |
2320 | 2324 | }); |
2321 | 2325 | expect(getActiveMemoryLines(sessionKey)).toEqual( |
2322 | 2326 | expect.arrayContaining([ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -13,6 +13,10 @@ async function withTempDir<T>(run: (tempDir: string) => Promise<T>): Promise<T>
|
13 | 13 | } |
14 | 14 | } |
15 | 15 | |
| 16 | +async function expectPathMissing(targetPath: string): Promise<void> { |
| 17 | +await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" }); |
| 18 | +} |
| 19 | + |
16 | 20 | describe("ensureOutputDirectory", () => { |
17 | 21 | it("creates nested missing output directories", async () => { |
18 | 22 | await withTempDir(async (tempDir) => { |
@@ -37,7 +41,7 @@ describe("ensureOutputDirectory", () => {
|
37 | 41 | await expect(ensureOutputDirectory(path.join(symlinkDir, "nested"))).rejects.toThrow( |
38 | 42 | /symlink|output directory/i, |
39 | 43 | ); |
40 | | -await expect(fs.access(path.join(outsideDir, "nested"))).rejects.toThrow(); |
| 44 | +await expectPathMissing(path.join(outsideDir, "nested")); |
41 | 45 | }); |
42 | 46 | }, |
43 | 47 | ); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -64,6 +64,10 @@ import {
|
64 | 64 | } from "./api.js"; |
65 | 65 | import registerDevicePair from "./index.js"; |
66 | 66 | |
| 67 | +async function expectPathMissing(targetPath: string): Promise<void> { |
| 68 | +await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" }); |
| 69 | +} |
| 70 | + |
67 | 71 | afterAll(() => { |
68 | 72 | vi.doUnmock("./api.js"); |
69 | 73 | vi.doUnmock("./notify.js"); |
@@ -491,7 +495,7 @@ describe("device-pair /pair qr", () => {
|
491 | 495 | expect(opts.mediaLocalRoots).toEqual([path.dirname(mediaUrl)]); |
492 | 496 | expect(opts).toMatchObject(testCase.expectedOpts); |
493 | 497 | expect(sentPng).toBe("fakepng"); |
494 | | -await expect(fs.access(mediaUrl)).rejects.toThrow(); |
| 498 | +await expectPathMissing(mediaUrl); |
495 | 499 | expect(text).toContain("QR code sent above."); |
496 | 500 | expect(text).toContain("IMPORTANT: Run /pair cleanup after pairing finishes."); |
497 | 501 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -8,6 +8,10 @@ import { createMemoryWikiTestHarness } from "./test-helpers.js";
|
8 | 8 | |
9 | 9 | const { createVault } = createMemoryWikiTestHarness(); |
10 | 10 | |
| 11 | +async function expectPathMissing(targetPath: string): Promise<void> { |
| 12 | +await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" }); |
| 13 | +} |
| 14 | + |
11 | 15 | describe("compileMemoryWikiVault", () => { |
12 | 16 | let suiteRoot = ""; |
13 | 17 | let caseId = 0; |
@@ -368,7 +372,7 @@ describe("compileMemoryWikiVault", () => {
|
368 | 372 | |
369 | 373 | await compileMemoryWikiVault(config); |
370 | 374 | |
371 | | -await expect(fs.access(path.join(rootDir, "reports", "open-questions.md"))).rejects.toThrow(); |
| 375 | +await expectPathMissing(path.join(rootDir, "reports", "open-questions.md")); |
372 | 376 | }); |
373 | 377 | |
374 | 378 | it("writes agent directory, relationship, provenance, and privacy reports", async () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。