mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat(jobs)!: SnapOtter 2.0 phase 2 job spine: async queues, worker pools, object storage, admin dashboard (#217)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { sql } from "drizzle-orm";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { db } from "../../apps/api/src/db/index.js";
|
||||
|
||||
describe("jobs table (phase 2 spine)", () => {
|
||||
it("has the spine columns and canceled status", async () => {
|
||||
const cols = await db.execute(
|
||||
sql`SELECT column_name FROM information_schema.columns WHERE table_name = 'jobs'`,
|
||||
);
|
||||
const names = cols.rows.map((r) => r.column_name);
|
||||
for (const expected of [
|
||||
"user_id",
|
||||
"tool_id",
|
||||
"pool",
|
||||
"attempts",
|
||||
"input_refs",
|
||||
"output_refs",
|
||||
"bytes_in",
|
||||
"bytes_out",
|
||||
"duration_ms",
|
||||
"started_at",
|
||||
"progress",
|
||||
"error",
|
||||
]) {
|
||||
expect(names).toContain(expected);
|
||||
}
|
||||
const enumRows = await db.execute(sql`SELECT unnest(enum_range(NULL::job_status))::text AS v`);
|
||||
expect(enumRows.rows.map((r) => r.v)).toContain("canceled");
|
||||
await db.execute(
|
||||
sql`INSERT INTO jobs (id, type, status, progress, input_refs, created_at) VALUES ('schema-test', 'single', 'canceled', '{"percent":50}', '["uploads/x"]', now())`,
|
||||
);
|
||||
await db.execute(sql`DELETE FROM jobs WHERE id = 'schema-test'`);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user