Public: anyone can read this; the crew can change it.
Full suite red: 2 files in check run 01m7j603sfecehdhmcs96tada3 #14215
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/14214-full-suite-red-2-files-in-check-run-01m7 → main 3 commits fork 2 threads · 2 unresolved
1 file
changed +17
−11
test/quotas-storage.test.ts +17 −11
| @@ -15,7 +15,8 @@ import { newApp } from "../src/actions/apps.ts"; | ||
| 15 | 15 | import { signUp } from "../src/actions/users.ts"; |
| 16 | 16 | import { createToken } from "../src/core/tokens.ts"; |
| 17 | 17 | import { REWALK_MS, accountBytes, formatBytes, storageRefusal } from "../src/core/storage.ts"; |
| 18 | import { getRepo } from "../src/core/repos.ts"; | |
| 18 | import { getRepo, type Repo } from "../src/core/repos.ts"; | |
| 19 | ||
| 19 | 20 | import { createAgent } from "../src/actions/crew.ts"; |
| 20 | 21 | import { mirrorAndWait, newFakeState, serveFakeForge } from "./fake-origin.ts"; |
| 21 | 22 | import { serveGitCommand } from "../src/tui/ssh.ts"; |
| @@ -34,6 +35,8 @@ import { seedAdmin } from "./helpers/admin.ts"; | ||
| 34 | 35 | describe("storage quota", () => { |
| 35 | 36 | let dataDir: string; |
| 36 | 37 | let app: App; |
| 38 | /** Public parents the fork test forks in turn, made once in the setup. */ | |
| 39 | let forkParents: Repo[] = []; | |
Non-blocking: use const, since the array is never reassigned. |
||
| 37 | 40 | let servers: Servers; |
| 38 | 41 | let adaId: string; |
| 39 | 42 | let adaToken: string; |
| @@ -84,6 +87,12 @@ describe("storage quota", () => { | ||
| 84 | 87 | // 1 MB limit, on this same forge, pushed once here so neither test pays for it. |
| 85 | 88 | expect((await push("ada", adaToken, "bigorigin", 1_100_000)).code).toBe(0); |
| 86 | 89 | app.db.query("UPDATE repo SET visibility = 'public' WHERE name = 'bigorigin'").run(); |
| 90 | for (let i = 0; i < 8; i++) { | |
| 91 | const parent = await createRepo(app, ada.value, { name: `src${i}`, visibility: "public" }); | |
| 92 | if (!parent.ok) throw new Error(parent.error); | |
| 93 | await commitToBranch(app, ada.value, parent.value, { message: "seed", files: [{ path: "a.txt", content: "a\n" }] }); | |
| 94 | forkParents.push(parent.value); | |
| 95 | } | |
| 87 | 96 | // gina imports it by migrate: let in because her account is empty. |
| 88 | 97 | const state = newFakeState("forgejo", "someone", "tok"); |
| 89 | 98 | state.repos.push({ |
| @@ -228,19 +237,16 @@ describe("storage quota", () => { | ||
| 228 | 237 | const filled = await push("carol", carolToken, "base", 900_000); |
| 229 | 238 | expect(filled.code).toBe(0); |
| 230 | 239 | const carol = getUserById(app.db, carolId)!; |
| 231 | const ada = getUserById(app.db, adaId)!; | |
| 232 | 240 | let refused: string | undefined; |
| 233 | 241 | let made = 0; |
| 234 | for (let i = 0; i < 60 && refused === undefined; i++) { | |
| 235 | const parent = await createRepo(app, ada, { name: `src${i}`, visibility: "public" }); | |
| 236 | if (!parent.ok) throw new Error(parent.error); | |
| 237 | await commitToBranch(app, ada, parent.value, { | |
| 238 | message: "seed", | |
| 239 | files: [{ path: "a.txt", content: "a\n" }], | |
| 240 | }); | |
| 241 | const forked = await forkRepo(app, carol, parent.value); | |
| 242 | // The parents were made once, in the setup: only the forks are the test's own work. | |
| 243 | for (const parent of forkParents) { | |
| 244 | const forked = await forkRepo(app, carol, parent); | |
| 242 | 245 | if (forked.ok) made++; |
| 243 | else refused = forked.error; | |
| 246 | else { | |
| 247 | refused = forked.error; | |
| 248 | break; | |
| 249 | } | |
| 244 | 250 | } |
| 245 | 251 | expect(made).toBeGreaterThan(0); |
| 246 | 252 | expect(refused).toBe("storage_limit"); |
new above
offline
Non-blocking: this blank line splits the import block and should go.