|
1 | | -import { readFile, writeFile } from "node:fs/promises"; |
| 1 | +import { readFile, stat, writeFile } from "node:fs/promises"; |
2 | 2 | import { join } from "node:path"; |
3 | 3 | import { fileURLToPath } from "node:url"; |
4 | 4 | import { expect } from "vitest"; |
@@ -187,16 +187,17 @@ registerHooks({ load(url, context, nextLoad) { |
187 | 187 | const { run }: { run: string } = JSON.parse( |
188 | 188 | await readFile(receipt, "utf8"), |
189 | 189 | ); |
| 190 | + // Copied authentication is removed even when the owned command stays |
| 191 | + // incomplete. The run directory stays until that command releases. |
| 192 | + await expect(readFile(join(run, "codex/auth.json"))).rejects.toMatchObject({ |
| 193 | + code: "ENOENT", |
| 194 | + }); |
190 | 195 | if (incomplete) { |
191 | 196 | expect(result.stderr).toContain("Artifact cleanup remains incomplete"); |
192 | 197 | expect(result.stderr).toContain("fixture cleanup denied"); |
193 | | - expect(await readFile(join(run, "codex/auth.json"), "utf8")).toBe( |
194 | | - "inert fixture", |
195 | | - ); |
| 198 | + expect((await stat(run)).isDirectory()).toBe(true); |
196 | 199 | } else { |
197 | | - await expect( |
198 | | - readFile(join(run, "codex/auth.json")), |
199 | | - ).rejects.toMatchObject({ code: "ENOENT" }); |
| 200 | + await expect(stat(run)).rejects.toMatchObject({ code: "ENOENT" }); |
200 | 201 | } |
201 | 202 | }, |
202 | 203 | ); |
@@ -295,16 +296,19 @@ registerHooks({ load(url, context, nextLoad) { |
295 | 296 | expect(await readFile(retried, "utf8")).toBe( |
296 | 297 | "exact preparation owner retried", |
297 | 298 | ); |
| 299 | + // Copied authentication is removed even when preparation stays incomplete. |
| 300 | + // The run directory stays until that command releases. |
| 301 | + await expect( |
| 302 | + readFile(join(observed.run, "codex/auth.json")), |
| 303 | + ).rejects.toMatchObject({ code: "ENOENT" }); |
298 | 304 | if (incomplete) { |
299 | 305 | expect(result.stderr).toContain("Artifact cleanup remains incomplete"); |
300 | 306 | expect(result.stderr).toContain("darwin-fixture-reader"); |
301 | | - expect( |
302 | | - await readFile(join(observed.run, "codex/auth.json"), "utf8"), |
303 | | - ).toBe("inert preparation fixture"); |
| 307 | + expect((await stat(observed.run)).isDirectory()).toBe(true); |
304 | 308 | } else { |
305 | | - await expect( |
306 | | - readFile(join(observed.run, "codex/auth.json")), |
307 | | - ).rejects.toMatchObject({ code: "ENOENT" }); |
| 309 | + await expect(stat(observed.run)).rejects.toMatchObject({ |
| 310 | + code: "ENOENT", |
| 311 | + }); |
308 | 312 | } |
309 | 313 | }, |
310 | 314 | ); |
0 commit comments