style: fix deno fmt on students tests and drizzle.config
This commit is contained in:
+3
-1
@@ -2,7 +2,9 @@ import { defineConfig } from "drizzle-kit";
|
|||||||
import process from "node:process";
|
import process from "node:process";
|
||||||
|
|
||||||
const url = process.env.DATABASE_URL ??
|
const url = process.env.DATABASE_URL ??
|
||||||
`postgresql://${process.env.POSTGRES_USER}:${process.env.POSTGRES_PASS}@${process.env.POSTGRES_HOST ?? "localhost"}:${process.env.POSTGRES_PORT ?? 5432}/${process.env.POSTGRES_DB}`;
|
`postgresql://${process.env.POSTGRES_USER}:${process.env.POSTGRES_PASS}@${
|
||||||
|
process.env.POSTGRES_HOST ?? "localhost"
|
||||||
|
}:${process.env.POSTGRES_PORT ?? 5432}/${process.env.POSTGRES_DB}`;
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
dialect: "postgresql",
|
dialect: "postgresql",
|
||||||
|
|||||||
@@ -80,7 +80,10 @@ Deno.test({
|
|||||||
assertEquals(res.status, 200);
|
assertEquals(res.status, 200);
|
||||||
const body = await res.json();
|
const body = await res.json();
|
||||||
assertEquals(body.length, 2);
|
assertEquals(body.length, 2);
|
||||||
assertEquals(body.every((s: { idPromo: string }) => s.idPromo === "PEIP1-2024"), true);
|
assertEquals(
|
||||||
|
body.every((s: { idPromo: string }) => s.idPromo === "PEIP1-2024"),
|
||||||
|
true,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
sanitizeResources: false,
|
sanitizeResources: false,
|
||||||
sanitizeOps: false,
|
sanitizeOps: false,
|
||||||
|
|||||||
@@ -65,7 +65,12 @@ Deno.test("mock API: GET /students/:numEtud returns one student", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Deno.test("mock API: GET /students/:numEtud 404 when not found", async () => {
|
Deno.test("mock API: GET /students/:numEtud 404 when not found", async () => {
|
||||||
mockFetch({ "/students/99999": { status: 404, body: { error: "Ressource introuvable" } } });
|
mockFetch({
|
||||||
|
"/students/99999": {
|
||||||
|
status: 404,
|
||||||
|
body: { error: "Ressource introuvable" },
|
||||||
|
},
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
const res = await fetch("http://localhost/api/students/99999");
|
const res = await fetch("http://localhost/api/students/99999");
|
||||||
assertEquals(res.status, 404);
|
assertEquals(res.status, 404);
|
||||||
@@ -81,7 +86,11 @@ Deno.test("mock API: POST /students creates student", async () => {
|
|||||||
const res = await fetch("http://localhost/api/students", {
|
const res = await fetch("http://localhost/api/students", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "content-type": "application/json" },
|
headers: { "content-type": "application/json" },
|
||||||
body: JSON.stringify({ nom: "Dupont", prenom: "Jean", idPromo: "4AFISE25/26" }),
|
body: JSON.stringify({
|
||||||
|
nom: "Dupont",
|
||||||
|
prenom: "Jean",
|
||||||
|
idPromo: "4AFISE25/26",
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
assertEquals(res.status, 201);
|
assertEquals(res.status, 201);
|
||||||
const data: Student = await res.json();
|
const data: Student = await res.json();
|
||||||
@@ -93,12 +102,18 @@ Deno.test("mock API: POST /students creates student", async () => {
|
|||||||
|
|
||||||
Deno.test("mock API: PUT /students/:numEtud updates student", async () => {
|
Deno.test("mock API: PUT /students/:numEtud updates student", async () => {
|
||||||
const updated = { ...students[0], nom: "Dupont-Modifié" };
|
const updated = { ...students[0], nom: "Dupont-Modifié" };
|
||||||
mockFetch({ "/students/21212006": { method: "PUT", status: 200, body: updated } });
|
mockFetch({
|
||||||
|
"/students/21212006": { method: "PUT", status: 200, body: updated },
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
const res = await fetch("http://localhost/api/students/21212006", {
|
const res = await fetch("http://localhost/api/students/21212006", {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: { "content-type": "application/json" },
|
headers: { "content-type": "application/json" },
|
||||||
body: JSON.stringify({ nom: "Dupont-Modifié", prenom: "Jean", idPromo: "4AFISE25/26" }),
|
body: JSON.stringify({
|
||||||
|
nom: "Dupont-Modifié",
|
||||||
|
prenom: "Jean",
|
||||||
|
idPromo: "4AFISE25/26",
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
assertEquals(res.status, 200);
|
assertEquals(res.status, 200);
|
||||||
const data: Student = await res.json();
|
const data: Student = await res.json();
|
||||||
|
|||||||
Reference in New Issue
Block a user