Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 07b6f1e347 | |||
| c5018d9ced |
@@ -1,58 +0,0 @@
|
|||||||
import { assertEquals, assertExists } from "@std/assert";
|
|
||||||
import {
|
|
||||||
closeTestPool,
|
|
||||||
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,
|
|
||||||
});
|
|
||||||
|
|
||||||
Deno.test({
|
|
||||||
name: "integration: cleanup - close pool",
|
|
||||||
async fn() {
|
|
||||||
await closeTestPool();
|
|
||||||
},
|
|
||||||
sanitizeResources: false,
|
|
||||||
sanitizeOps: false,
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user