c5018d9ced
Covers full CRUD for each resource via testDb: - promotions: list, create, get by id, not found, update, delete - students: list, filter by promo, create, get, not found, update, delete - roles: list, create, get with permissions, update+reset perms, delete - modules: list, create, duplicate id rejection, get, not found, update, delete 27 integration tests passing in CI (act + Gitea Actions). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { assertEquals, assertExists } from "@std/assert";
|
|
import {
|
|
seedRoles,
|
|
seedUsers,
|
|
testDb,
|
|
truncateAll,
|
|
} from "../helpers/db_integration.ts";
|
|
import { users } from "$root/databases/schema.ts";
|
|
|
|
Deno.test({
|
|
name: "integration: GET /users - DB round trip",
|
|
async fn() {
|
|
await truncateAll();
|
|
|
|
const [role] = await seedRoles([{ nom: "employee" }]);
|
|
await seedUsers([
|
|
{ id: "dupont.jean", nom: "Dupont", prenom: "Jean", idRole: role.id },
|
|
{ id: "martin.alice", nom: "Martin", prenom: "Alice", idRole: role.id },
|
|
]);
|
|
|
|
const rows = await testDb.select().from(users);
|
|
assertEquals(rows.length, 2);
|
|
assertExists(rows.find((u) => u.id === "dupont.jean"));
|
|
},
|
|
sanitizeResources: false,
|
|
sanitizeOps: false,
|
|
});
|
|
|
|
Deno.test({
|
|
name: "integration: INSERT user and retrieve by id",
|
|
async fn() {
|
|
await truncateAll();
|
|
|
|
const [role] = await seedRoles([{ nom: "admin" }]);
|
|
const [created] = await testDb.insert(users).values({
|
|
id: "durand.claire",
|
|
nom: "Durand",
|
|
prenom: "Claire",
|
|
idRole: role.id,
|
|
}).returning();
|
|
|
|
assertExists(created);
|
|
assertEquals(created.id, "durand.claire");
|
|
assertEquals(created.nom, "Durand");
|
|
},
|
|
sanitizeResources: false,
|
|
sanitizeOps: false,
|
|
});
|
|
|