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

Full suite red: test/flow-alarm-drift.test.ts #12852

Merged opened this in answer to

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

Merged

scout/forge:scout/12839-full-suite-red-test-flow-alarm-drift-tes → main 1 commit fork

  • Merged. scout/12839-full-suite-red-test-flow-alarm-drift-tes was merged into main as 324b7a7.

Review

Sign in to review this change.
1 file changed +15 −7
test/flow-alarm-drift.test.ts +15 −7
@@ -51,6 +51,17 @@ test("by hours: past 6 h fires; says the three most behind", () => {
5151 expect(driftAlarm([], NOW)).toEqual({ fired: false, says: "No open pull is drifting from main." });
5252 });
5353
54 /** Land n commits on main in one git process; the same as n pushes for what drift reads. */
55 async function landMany(dir: string, n: number, tag: string): Promise<void> {
56 let input = "";
57 for (let i = 0; i < n; i++) {
58 const body = "x\n";
59 input += `commit refs/heads/main\ncommitter t <t@t> ${Math.floor(Date.now() / 1000)} +0000\ndata ${tag.length + String(i).length}\n${tag}${i}\n${i === 0 ? "from refs/heads/main^0\n" : ""}M 100644 inline ${tag}${i}.txt\ndata ${body.length}\n${body}\n`;
60 }
61 const p = Bun.spawn(["git", "fast-import", "--quiet"], { cwd: dir, stdin: new Blob([input]), stdout: "ignore", stderr: "pipe" });
62 if ((await p.exited) !== 0) throw new Error(await new Response(p.stderr).text());
63 }
64
5465 let dataDir: string;
5566 let app: App;
5667
@@ -69,10 +80,9 @@ test("read from git: landings past a pull's base, open pulls only", async () =>
6980 const repo = ok(await createRepo(app.db, app.reposRoot, { ownerId: ada.id, name: "svc", visibility: "public" }));
7081 const dir = repoDir(app.reposRoot, ada.username, repo.name);
7182 const land = async (n: number) => {
72 for (let i = 0; i < n; i++)
73 ok(await commitToBranch(app, ada, repo, { message: `m${i}`, files: [{ path: `f${Math.random()}.txt`, content: "x\n" }] }));
83 await landMany(dir, n, `m${Math.random().toString(36).slice(2)}`);
7484 };
75 await land(1);
85 ok(await commitToBranch(app, ada, repo, { message: "seed", files: [{ path: "seed.txt", content: "x\n" }] }));
7686 const branch = (b: string) =>
7787 commitToBranch(app, ada, repo, { message: b, branch: b, files: [{ path: `${b}.txt`, content: "x\n" }] } as any);
7888 ok(await branch("one"));
@@ -122,8 +132,7 @@ test("a rebased head stops counting; a merged pull never counts", async () => {
122132 ok(await commitToBranch(app, ada, repo, { message: "seed", files: [{ path: "a.txt", content: "a\n" }] }));
123133 ok(await commitToBranch(app, ada, repo, { message: "w", branch: "work", files: [{ path: "w.txt", content: "w\n" }] } as any));
124134 const pull = ok(await createPull(app.db, dir, { repoId: repo.id, authorId: ada.id, title: "w", baseBranch: "main", headBranch: "work" }));
125 for (let i = 0; i < 26; i++)
126 ok(await commitToBranch(app, ada, repo, { message: `m${i}`, files: [{ path: `g${i}.txt`, content: "x\n" }] }));
135 await landMany(dir, 26, "g");
127136 expect((await alarmDrift(app, new Date())).fired).toBe(true);
128137 // Merge main into the head and tell the pull, as a push does.
129138 const merged = await git("commit-tree", "main^{tree}", "-p", "work", "-p", "main", "-m", "merge main");
@@ -132,8 +141,7 @@ test("a rebased head stops counting; a merged pull never counts", async () => {
132141 app.db.query("UPDATE pull SET head_oid = ?1 WHERE issue_id = ?2").run(merged, pull.id);
133142 expect((await alarmDrift(app, new Date())).fired).toBe(false);
134143 // Behind again, but merged: never counts.
135 for (let i = 0; i < 26; i++)
136 ok(await commitToBranch(app, ada, repo, { message: `n${i}`, files: [{ path: `h${i}.txt`, content: "x\n" }] }));
144 await landMany(dir, 26, "h");
137145 expect((await alarmDrift(app, new Date())).fired).toBe(true);
138146 app.db.query("UPDATE pull SET merged_at = ?1 WHERE issue_id = ?2").run(new Date().toISOString(), pull.id);
139147 expect((await alarmDrift(app, new Date())).fired).toBe(false);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs