Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions cloudflare/test/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ async function state() {

beforeEach(async () => {
await env.DB.batch([
env.DB.prepare("DELETE FROM github_deliveries"),
env.DB.prepare("DELETE FROM github_projects"),
env.DB.prepare("DELETE FROM github_installations"),
env.DB.prepare(
"INSERT OR IGNORE INTO user(id,name,email,emailVerified,createdAt,updatedAt) VALUES('app-test','Tester','app-test@example.com',1,0,0)",
"INSERT INTO user(id,name,email,emailVerified,createdAt,updatedAt) VALUES('app-test','Tester','app-test@example.com',1,0,0)",
),
env.DB.prepare(
"INSERT OR IGNORE INTO account(id,accountId,providerId,userId,createdAt,updatedAt) VALUES('app-test-account','7','github','app-test',0,0)",
"INSERT INTO account(id,accountId,providerId,userId,createdAt,updatedAt) VALUES('app-test-account','7','github','app-test',0,0)",
),
]);
});
Expand Down
6 changes: 0 additions & 6 deletions cloudflare/test/inbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ let github: Awaited<ReturnType<typeof maintainerOf>>["github"];
let mock: Awaited<ReturnType<typeof maintainerOf>>["mock"];

beforeEach(async () => {
await db.batch([
db.prepare("DELETE FROM jobs"),
db.prepare("DELETE FROM runners"),
db.prepare("DELETE FROM github_projects"),
db.prepare("DELETE FROM github_installations"),
]);
({ user, cookie, github, mock } = await maintainerOf());
});
afterEach(() => vi.restoreAllMocks());
Expand Down
9 changes: 1 addition & 8 deletions cloudflare/test/jobs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const testEnv = { ...env, GITHUB_APP_PRIVATE_KEY: privateKey };
const db = env.DB;
async function user(id: string) {
await db
.prepare("INSERT OR IGNORE INTO user(id,name,email,emailVerified,createdAt,updatedAt) VALUES(?,?,?,1,0,0)")
.prepare("INSERT INTO user(id,name,email,emailVerified,createdAt,updatedAt) VALUES(?,?,?,1,0,0)")
.bind(id, id, `${id}@example.test`)
.run();
}
Expand Down Expand Up @@ -62,13 +62,6 @@ async function run(slots: Record<string, number>, now: number, owner = "owner",
}

beforeEach(async () => {
await db.batch([
db.prepare("DELETE FROM jobs"),
db.prepare("DELETE FROM runners"),
db.prepare("DELETE FROM github_projects"),
db.prepare("DELETE FROM github_installations"),
db.prepare("DELETE FROM output_cleanup"),
]);
await user("owner");
await user("other");
await project(10, "owner");
Expand Down
7 changes: 2 additions & 5 deletions cloudflare/test/projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,12 @@ async function state() {

beforeEach(async () => {
await env.DB.batch([
env.DB.prepare("DELETE FROM github_projects"),
env.DB.prepare("DELETE FROM github_installations"),
env.DB.prepare(
"INSERT OR IGNORE INTO user(id,name,email,emailVerified,createdAt,updatedAt) VALUES('enrollment-test','Maintainer','enrollment-test@example.test',1,0,0)",
"INSERT INTO user(id,name,email,emailVerified,createdAt,updatedAt) VALUES('enrollment-test','Maintainer','enrollment-test@example.test',1,0,0)",
),
env.DB.prepare(
"INSERT OR IGNORE INTO account(id,accountId,providerId,userId,createdAt,updatedAt) VALUES('enrollment-account','7007','github','enrollment-test',0,0)",
"INSERT INTO account(id,accountId,providerId,userId,createdAt,updatedAt) VALUES('enrollment-account','7007','github','enrollment-test',0,0)",
),
env.DB.prepare("UPDATE account SET accountId='7007' WHERE userId='enrollment-test'"),
]);
});
afterEach(() => vi.restoreAllMocks());
Expand Down
10 changes: 3 additions & 7 deletions cloudflare/test/publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,12 @@ async function job(id: string) {

beforeEach(async () => {
await db.batch([
db.prepare("DELETE FROM jobs"),
db.prepare("DELETE FROM runners"),
db.prepare("DELETE FROM github_projects"),
db.prepare("DELETE FROM github_installations"),
db
.prepare("INSERT OR IGNORE INTO user(id,name,email,emailVerified,createdAt,updatedAt) VALUES(?,?,?,1,0,0)")
.prepare("INSERT INTO user(id,name,email,emailVerified,createdAt,updatedAt) VALUES(?,?,?,1,0,0)")
.bind(user, user, `${user}@example.test`),
db
.prepare(
"INSERT OR IGNORE INTO account(id,accountId,providerId,userId,createdAt,updatedAt) VALUES(?,?,'github',?,0,0)",
"INSERT INTO account(id,accountId,providerId,userId,createdAt,updatedAt) VALUES(?,?,'github',?,0,0)",
)
.bind(`${user}-account`, String(githubUser), user),
db
Expand Down Expand Up @@ -693,7 +689,7 @@ describe("runner publication", () => {
expect(blocked.status).toBe(202);
const question = (await job(id)).questions[0]!.id;
await db
.prepare("INSERT OR IGNORE INTO user(id,name,email,emailVerified,createdAt,updatedAt) VALUES(?,?,?,1,0,0)")
.prepare("INSERT INTO user(id,name,email,emailVerified,createdAt,updatedAt) VALUES(?,?,?,1,0,0)")
.bind("other", "other", "other@example.test")
.run();
const { resumed } = await store.answer(db, id, question, "other", "Keep going", Date.now());
Expand Down
6 changes: 0 additions & 6 deletions cloudflare/test/push.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@ describe("decision notifications", () => {
let respond: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;

beforeEach(async () => {
await db.batch([
db.prepare("DELETE FROM push_subscriptions"),
db.prepare("DELETE FROM jobs"),
db.prepare("DELETE FROM runners"),
db.prepare("DELETE FROM github_projects"),
]);
const maintainer = await maintainerOf();
({ user, cookie, github } = maintainer);
sent = [];
Expand Down
3 changes: 1 addition & 2 deletions cloudflare/test/runners.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ let cookie = "";
let owner = "";

beforeEach(async () => {
await db.prepare("DELETE FROM runners").run();
const who = identity("github");
cookie = (await oauth(who)).session!;
owner = (await db
Expand Down Expand Up @@ -68,7 +67,7 @@ describe("runner login", () => {

it("refuses a key another account already connected", async () => {
await db
.prepare("INSERT OR IGNORE INTO user(id,name,email,emailVerified,createdAt,updatedAt) VALUES(?,?,?,1,0,0)")
.prepare("INSERT INTO user(id,name,email,emailVerified,createdAt,updatedAt) VALUES(?,?,?,1,0,0)")
.bind("someone", "someone", "someone@example.test")
.run();
await store.registerRunner(db, "someone", "theirs", "linux", false, await key(), 0);
Expand Down
6 changes: 0 additions & 6 deletions cloudflare/test/seed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ afterEach(() => vi.restoreAllMocks());
* returning it, a request helper, and the session cookie.
*/
async function seeded(edit: (world: World) => void = () => {}) {
await db.batch([
db.prepare("DELETE FROM jobs"),
db.prepare("DELETE FROM runners"),
db.prepare("DELETE FROM github_projects"),
db.prepare("DELETE FROM github_installations"),
]);
const data = { ...world(), forks: env.GITHUB_FORK_OWNER };
edit(data);
vi.spyOn(globalThis, "fetch").mockImplementation(fakeGitHub(data));
Expand Down
11 changes: 9 additions & 2 deletions cloudflare/test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import { applyD1Migrations } from "cloudflare:test";
import { applyD1Migrations, reset } from "cloudflare:test";
import { env } from "cloudflare:workers";
await applyD1Migrations(env.DB, env.TEST_MIGRATIONS);
import { beforeEach } from "vitest";

// Every test starts from empty, freshly migrated storage, so none depends on
// rows, objects, or Durable Objects another test left behind.
beforeEach(async () => {
await reset();
await applyD1Migrations(env.DB, env.TEST_MIGRATIONS);
});
2 changes: 0 additions & 2 deletions cloudflare/test/worker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ describe("Worker", () => {
"/%5cevil.example",
].map((next) => [next, "/inbox"]),
])("returns to a local page after signing in: %j -> %j", async (next, expected) => {
// Better Auth stores each sign-in's callback with its OAuth state.
await env.DB.prepare("DELETE FROM verification").run();
const response = await SELF.fetch(`${origin}/sign-in`, {
method: "POST",
headers: { Origin: origin },
Expand Down
10 changes: 9 additions & 1 deletion cloudflare/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,13 @@ export default defineConfig({
// (the pool appends `import main` to cloudflare:test), all transformed by vitest's
// one Node process, which also answers a module resolve for every SELF.fetch.
// One shared runtime imports the Worker once, so a busy host can't stall the tests.
test: { setupFiles: ["./test/setup.ts"], fileParallelism: false, isolate: false },
// test/setup.ts resets storage before each test, and every run shuffles files and
// tests, so a test that depends on another's leftovers fails (rerun with the
// printed seed: `vitest run --sequence.seed=<seed>`).
test: {
setupFiles: ["./test/setup.ts"],
fileParallelism: false,
isolate: false,
sequence: { shuffle: true },
},
});
1 change: 0 additions & 1 deletion quest/m0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ ownership-manifest design:

## Required

- [Worker tests](/quest/m0/worker-tests.md) - every Worker test passes alone and in any order
- [Gate bench](/quest/m0/gate-bench.md) - measure headroom admission on an idle host
- [Agent lifecycle integration](/quest/m0/worktree-agents.md) - reclaim completed and suspended checkouts through their harness
- [Agent workflow helpers](/quest/m0/helpers/README.md) - CLI commands for CI waits, PR status, claims, quest moves, and serialized merges
Expand Down
22 changes: 0 additions & 22 deletions quest/m0/worker-tests.md

This file was deleted.

Loading