Skip to content

Commit f28ce3d

Browse files
committed
test: improve visibility of throws in approve/reject push test
1 parent 814455c commit f28ce3d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

test/testDb.test.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,26 +589,35 @@ describe('Database clients', async () => {
589589
});
590590

591591
it('should be able to check if a user can approve/reject push', async function () {
592-
let threwError = false;
592+
let allowed = undefined;
593593
const repoName = trimTrailingDotGit(TEST_PUSH.repoName);
594+
594595
try {
595596
// push does not exist yet, should return false
596-
let allowed = await db.canUserApproveRejectPush(TEST_PUSH.id, TEST_USER.username);
597+
allowed = await db.canUserApproveRejectPush(TEST_PUSH.id, TEST_USER.username);
597598
expect(allowed).to.be.false;
599+
} catch (e) {
600+
expect.fail(e);
601+
}
598602

603+
try {
599604
// create the push - user should already exist and not authorised to push
600605
await db.writeAudit(TEST_PUSH);
601606
allowed = await db.canUserApproveRejectPush(TEST_PUSH.id, TEST_USER.username);
602607
expect(allowed).to.be.false;
608+
} catch (e) {
609+
expect.fail(e);
610+
}
603611

612+
try {
604613
// authorise user and recheck
605614
await db.addUserCanAuthorise(repoName, TEST_USER.username);
606615
allowed = await db.canUserApproveRejectPush(TEST_PUSH.id, TEST_USER.username);
607616
expect(allowed).to.be.true;
608617
} catch (e) {
609-
threwError = true;
618+
expect.fail(e);
610619
}
611-
expect(threwError).to.be.false;
620+
612621
// clean up
613622
await db.deletePush(TEST_PUSH.id);
614623
await db.removeUserCanAuthorise(repoName, TEST_USER.username);

0 commit comments

Comments
 (0)