Download apps/api/src/__tests__/sqlite-store.test.ts from Lazywords/Rl-Auto: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/Lazywords/Rl-Auto/resolve/main/apps/api/src/__tests__/sqlite-store.test.ts
- Command line
-
hf download hf://spaces/Lazywords/Rl-Auto/apps/api/src/__tests__/sqlite-store.test.ts
-
curl -L -o sqlite-store.test.ts https://huggingface.co/spaces/Lazywords/Rl-Auto/resolve/main/apps/api/src/__tests__/sqlite-store.test.ts
1.21 kB
| import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; | |
| import { tmpdir } from "node:os"; | |
| import { join } from "node:path"; | |
| import { describe, expect, it } from "vitest"; | |
| import { SqliteStore } from "../queue/store.js"; | |
| describe("SQLite queue store", () => { | |
| it("tracks attempts and exposes the next queued item atomically", () => { | |
| const dir = mkdtempSync(join(tmpdir(), "rl-auto-store-")); | |
| try { | |
| const store = new SqliteStore(join(dir, "tasks.db")); | |
| const uploadPath = join(dir, "recording.zip"); | |
| writeFileSync(uploadPath, "zip"); | |
| const job = store.createJob({}); | |
| const item = store.createItem({ | |
| jobId: job.id, | |
| ord: 1, | |
| filename: "recording.zip", | |
| uploadPath, | |
| detectedMode: "api", | |
| }); | |
| const first = store.takeNextQueuedItem(job.id); | |
| const second = store.takeNextQueuedItem(job.id); | |
| expect(first?.id).toBe(item.id); | |
| expect(first?.status).toBe("running"); | |
| expect(first?.attempt_count).toBe(1); | |
| expect(first?.last_stage).toBe("running"); | |
| expect(second).toBeNull(); | |
| store.close(); | |
| } finally { | |
| rmSync(dir, { recursive: true, force: true }); | |
| } | |
| }); | |
| }); | |