@@ -62,6 +62,13 @@ function readAuditLog(home: string): unknown[] {
|
62 | 62 | .map((line) => JSON.parse(line)); |
63 | 63 | } |
64 | 64 | |
| 65 | +function requireAuditRecord(value: unknown): Record<string, unknown> { |
| 66 | +if (!value || typeof value !== "object" || Array.isArray(value)) { |
| 67 | +throw new Error("Expected audit JSONL record"); |
| 68 | +} |
| 69 | +return value as Record<string, unknown>; |
| 70 | +} |
| 71 | + |
65 | 72 | describe("config io audit helpers", () => { |
66 | 73 | const suiteRootTracker = createSuiteTempRootTracker({ prefix: "openclaw-config-audit-" }); |
67 | 74 | |
@@ -189,11 +196,10 @@ describe("config io audit helpers", () => {
|
189 | 196 | |
190 | 197 | const records = readAuditLog(home); |
191 | 198 | expect(records).toHaveLength(1); |
192 | | -expect(records[0]).toMatchObject({ |
193 | | -event: "config.write", |
194 | | -result: "rename", |
195 | | -nextHash: "next-hash", |
196 | | -}); |
| 199 | +const written = requireAuditRecord(records[0]); |
| 200 | +expect(written.event).toBe("config.write"); |
| 201 | +expect(written.result).toBe("rename"); |
| 202 | +expect(written.nextHash).toBe("next-hash"); |
197 | 203 | }); |
198 | 204 | |
199 | 205 | it("redacts argv values that follow known secret flag names", () => { |
@@ -434,10 +440,9 @@ describe("config io audit helpers", () => {
|
434 | 440 | |
435 | 441 | const records = readAuditLog(home); |
436 | 442 | expect(records).toHaveLength(1); |
437 | | -expect(records[0]).toMatchObject({ |
438 | | -event: "config.write", |
439 | | -result: "rename", |
440 | | -nextHash: "next-hash", |
441 | | -}); |
| 443 | +const written = requireAuditRecord(records[0]); |
| 444 | +expect(written.event).toBe("config.write"); |
| 445 | +expect(written.result).toBe("rename"); |
| 446 | +expect(written.nextHash).toBe("next-hash"); |
442 | 447 | }); |
443 | 448 | }); |