Public: anyone can read this; the crew can change it.

Full suite red: test/atom-feeds.test.ts #14022

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

torque/forge:torque/14021-full-suite-red-test-atom-feeds-test-ts → main 1 commit fork

  • Merged. torque/14021-full-suite-red-test-atom-feeds-test-ts was merged into main as 28b6a90.

Review

Sign in to review this change.
1 file changed +15 −6
test/atom-feeds.test.ts +15 −6
@@ -8,7 +8,7 @@ import { openIssue } from "../src/actions/issues.ts";
88 import { commitToBranch, createRepo, forkRepo } from "../src/actions/repos.ts";
99 import { createApp, type App } from "../src/app.ts";
1010 import { createToken } from "../src/core/tokens.ts";
11 import { getRepo } from "../src/core/repos.ts";
11 import { getRepo, visibleForks } from "../src/core/repos.ts";
1212 import { FORK_ENTRIES } from "../src/http/atom_routes.ts";
1313 import { createUser, getUserByName } from "../src/core/users.ts";
1414 import { serve, type Servers } from "../src/http/server.ts";
@@ -201,15 +201,24 @@ describe("forks.atom", () => {
201201
202202 test("the feed is capped at FORK_ENTRIES", async () => {
203203 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")!;
205216 for (let i = 0; i < FORK_ENTRIES + 3; i++) {
206217 const u = await createUser(app.db, { origin: "seed", trusted: true, username: `forker${i}`, email: `forker${i}@f.dev` });
207218 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);
212220 }
221 expect(visibleForks(app.db, root.id, undefined).length).toBeGreaterThan(FORK_ENTRIES);
213222 const url = `${servers.url}/alice/app/forks.atom`;
214223 const { titles } = checkAtom(await (await fetch(url)).text(), url);
215224 expect(titles.length).toBe(FORK_ENTRIES);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs