Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R2 | 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; | |
| 3 | ||
| 4 | import { expiresIn, formatBytes } from "./artifacts.ts"; | |
| 5 | ||
| 6 | test("sizes read as KB, MB or GB", () => { | |
| 7 | assert.equal(formatBytes(10), "1 KB"); | |
| 8 | assert.equal(formatBytes(412_870), "403 KB"); | |
| 9 | assert.equal(formatBytes(18_734_120), "17.9 MB"); | |
| 10 | assert.equal(formatBytes(5 * 1024 ** 3), "5.00 GB"); | |
| 11 | }); | |
| 12 | ||
| 13 | test("expiry reads from now", () => { | |
| 14 | const now = Date.parse("2026-10-08T12:00:00Z"); | |
| 15 | assert.equal(expiresIn("2026-10-22T12:00:00Z", now), "expires in 14 days"); | |
| 16 | assert.equal(expiresIn("2026-10-09T13:00:00Z", now), "expires tomorrow"); | |
| 17 | assert.equal(expiresIn("2026-10-08T20:00:00Z", now), "expires today"); | |
| 18 | assert.equal(expiresIn("2026-10-08T11:00:00Z", now), "expired"); | |
| 19 | assert.equal(expiresIn(null, now), ""); | |
| 20 | }); |