Public: anyone can read this; the crew can change it.
Full suite red: test/atom-feeds.test.ts #14022
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/14021-full-suite-red-test-atom-feeds-test-ts → main 1 commit fork
1 file
changed +15
−6
test/atom-feeds.test.ts +15 −6
| @@ -8,7 +8,7 @@ import { openIssue } from "../src/actions/issues.ts"; | ||
| 8 | 8 | import { commitToBranch, createRepo, forkRepo } from "../src/actions/repos.ts"; |
| 9 | 9 | import { createApp, type App } from "../src/app.ts"; |
| 10 | 10 | import { createToken } from "../src/core/tokens.ts"; |
| 11 | import { getRepo } from "../src/core/repos.ts"; | |
| 11 | import { getRepo, visibleForks } from "../src/core/repos.ts"; | |
| 12 | 12 | import { FORK_ENTRIES } from "../src/http/atom_routes.ts"; |
| 13 | 13 | import { createUser, getUserByName } from "../src/core/users.ts"; |
| 14 | 14 | import { serve, type Servers } from "../src/http/server.ts"; |
| @@ -201,15 +201,24 @@ describe("forks.atom", () => { | ||
| 201 | 201 | |
| 202 | 202 | test("the feed is capped at FORK_ENTRIES", async () => { |
| 203 | 203 | const root = getRepo(app.db, "alice", "app")!; |
| 204 | // Accounts without a password skip argon2, which is what made this slow. | |
| 204 | // The feed reads rows, not git: one real fork (bobby's "openfork" exists), the rest copied | |
| 205 | // as rows under new owners, so 53 clones do not cost seconds. Accounts without a password | |
| 206 | // skip argon2. | |
| 207 | const cols = app.db | |
| 208 | .query<{ name: string }, []>("SELECT name FROM pragma_table_info('repo')") | |
| 209 | .all() | |
| 210 | .map((c) => c.name); | |
| 211 | const copy = (c: string) => (c === "id" ? "?1" : c === "owner_id" ? "?2" : c === "name" ? "?3" : c); | |
| 212 | const insert = app.db.prepare( | |
| 213 | `INSERT INTO repo (${cols.join(", ")}) SELECT ${cols.map(copy).join(", ")} FROM repo WHERE id = ?4`, | |
| 214 | ); | |
| 215 | const template = getRepo(app.db, "bobby", "openfork")!; | |
| 205 | 216 | for (let i = 0; i < FORK_ENTRIES + 3; i++) { |
| 206 | 217 | const u = await createUser(app.db, { origin: "seed", trusted: true, username: `forker${i}`, email: `forker${i}@f.dev` }); |
| 207 | 218 | if (!u.ok) throw new Error(u.error); |
| 208 | const promoted = setRole(app, getUserByName(app.db, "alice")!, `forker${i}`, "member"); | |
| 209 | if (!promoted.ok) throw new Error(promoted.error); | |
| 210 | const r = await forkRepo(app, u.value, root, `many${i}`); | |
| 211 | if (!r.ok) throw new Error(String(r.error)); | |
| 219 | insert.run(`forkrow${i}`, u.value.id, `many${i}`, template.id); | |
| 212 | 220 | } |
| 221 | expect(visibleForks(app.db, root.id, undefined).length).toBeGreaterThan(FORK_ENTRIES); | |
| 213 | 222 | const url = `${servers.url}/alice/app/forks.atom`; |
| 214 | 223 | const { titles } = checkAtom(await (await fetch(url)).text(), url); |
| 215 | 224 | expect(titles.length).toBe(FORK_ENTRIES); |
new above
offline