feat: centralize application framework primitives
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
createRepository,
|
||||
databaseHealth,
|
||||
retryTransaction,
|
||||
compareAndSet,
|
||||
} from "../src/index.ts";
|
||||
import type { Driver, Row } from "../src/index.ts";
|
||||
|
||||
@@ -28,6 +29,17 @@ function memoryDriver(): Driver {
|
||||
}
|
||||
|
||||
describe("database helper kit", () => {
|
||||
test("compareAndSet reports whether the guarded transition won", async () => {
|
||||
const db = createDb(memoryDriver());
|
||||
expect(
|
||||
await compareAndSet(db, {
|
||||
table: "messages",
|
||||
id: 1,
|
||||
from: "pending",
|
||||
to: "sending",
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
test("provides repository CRUD helpers and health checks", async () => {
|
||||
const db = createDb(memoryDriver());
|
||||
const repository = createRepository<{ id: number; name: string }>(db, {
|
||||
|
||||
Reference in New Issue
Block a user