ci: add pull request quality gates
CI / install-and-build (pull_request) Successful in 1m29s
CI / format (pull_request) Successful in 51s
CI / typecheck-source (pull_request) Successful in 41s
CI / typecheck-tests (pull_request) Successful in 39s
CI / test (pull_request) Successful in 51s
CI / lint (pull_request) Successful in 21s
CI / install-and-build (pull_request) Successful in 1m29s
CI / format (pull_request) Successful in 51s
CI / typecheck-source (pull_request) Successful in 41s
CI / typecheck-tests (pull_request) Successful in 39s
CI / test (pull_request) Successful in 51s
CI / lint (pull_request) Successful in 21s
Co-Authored-By: gpt-5.6-terra <noreply@openai.com>
This commit was merged in pull request #12.
This commit is contained in:
+21
-12
@@ -1,12 +1,15 @@
|
||||
import { describe, it, before, after } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import type { DbInterface } from "../../src/db/types/DbInterface.js";
|
||||
import { NotFoundAbodeError, InvalidAbodeError } from "../../src/db/types/errors.js";
|
||||
import {
|
||||
NotFoundAbodeError,
|
||||
InvalidAbodeError,
|
||||
} from "../../src/db/types/errors.js";
|
||||
import { hashPassword } from "../../src/util/hash.js";
|
||||
|
||||
export function runResidentTests(
|
||||
name: string,
|
||||
getDb: () => Promise<{ db: DbInterface; close(): void }>
|
||||
getDb: () => Promise<{ db: DbInterface; close(): void }>,
|
||||
): void {
|
||||
describe(`${name}: residents`, async () => {
|
||||
let db: DbInterface;
|
||||
@@ -36,7 +39,7 @@ export function runResidentTests(
|
||||
uid = resUser.uid;
|
||||
const abode = await db.createAbode(
|
||||
{ name: `Resident Abode ${Date.now()}` },
|
||||
{ uid: ctxUid }
|
||||
{ uid: ctxUid },
|
||||
);
|
||||
aid = abode.aid;
|
||||
await db.createResident({ uid, aid, flags: {} }, { uid: ctxUid });
|
||||
@@ -56,12 +59,12 @@ export function runResidentTests(
|
||||
() =>
|
||||
db.getResidentById(
|
||||
"00000000-0000-0000-0000-000000000000",
|
||||
"00000000-0000-0000-0000-000000000001"
|
||||
"00000000-0000-0000-0000-000000000001",
|
||||
),
|
||||
(err) => {
|
||||
assert.ok(err instanceof NotFoundAbodeError);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -101,7 +104,7 @@ export function runResidentTests(
|
||||
it("updateResident updates flags", async () => {
|
||||
const updated = await db.updateResident(
|
||||
{ uid, aid, flags: { admin: true } },
|
||||
{ uid: ctxUid }
|
||||
{ uid: ctxUid },
|
||||
);
|
||||
assert.equal(updated.uid, uid);
|
||||
assert.deepEqual(updated.flags, { admin: true });
|
||||
@@ -113,7 +116,7 @@ export function runResidentTests(
|
||||
(err) => {
|
||||
assert.ok(err instanceof InvalidAbodeError);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -125,15 +128,21 @@ export function runResidentTests(
|
||||
password: pw,
|
||||
flags: {},
|
||||
});
|
||||
const abode2 = await db.createAbode({ name: "Del Abode" }, { uid: ctxUid });
|
||||
await db.createResident({ uid: user2.uid, aid: abode2.aid, flags: {} }, { uid: ctxUid });
|
||||
const abode2 = await db.createAbode(
|
||||
{ name: "Del Abode" },
|
||||
{ uid: ctxUid },
|
||||
);
|
||||
await db.createResident(
|
||||
{ uid: user2.uid, aid: abode2.aid, flags: {} },
|
||||
{ uid: ctxUid },
|
||||
);
|
||||
await db.deleteResidentById(user2.uid, abode2.aid);
|
||||
await assert.rejects(
|
||||
() => db.getResidentById(user2.uid, abode2.aid),
|
||||
(err) => {
|
||||
assert.ok(err instanceof NotFoundAbodeError);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -142,12 +151,12 @@ export function runResidentTests(
|
||||
() =>
|
||||
db.deleteResidentById(
|
||||
"00000000-0000-0000-0000-000000000002",
|
||||
"00000000-0000-0000-0000-000000000003"
|
||||
"00000000-0000-0000-0000-000000000003",
|
||||
),
|
||||
(err) => {
|
||||
assert.ok(err instanceof NotFoundAbodeError);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user