File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -589,26 +589,35 @@ describe('Database clients', async () => {
589
589
} ) ;
590
590
591
591
it ( 'should be able to check if a user can approve/reject push' , async function ( ) {
592
- let threwError = false ;
592
+ let allowed = undefined ;
593
593
const repoName = trimTrailingDotGit ( TEST_PUSH . repoName ) ;
594
+
594
595
try {
595
596
// 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 ) ;
597
598
expect ( allowed ) . to . be . false ;
599
+ } catch ( e ) {
600
+ expect . fail ( e ) ;
601
+ }
598
602
603
+ try {
599
604
// create the push - user should already exist and not authorised to push
600
605
await db . writeAudit ( TEST_PUSH ) ;
601
606
allowed = await db . canUserApproveRejectPush ( TEST_PUSH . id , TEST_USER . username ) ;
602
607
expect ( allowed ) . to . be . false ;
608
+ } catch ( e ) {
609
+ expect . fail ( e ) ;
610
+ }
603
611
612
+ try {
604
613
// authorise user and recheck
605
614
await db . addUserCanAuthorise ( repoName , TEST_USER . username ) ;
606
615
allowed = await db . canUserApproveRejectPush ( TEST_PUSH . id , TEST_USER . username ) ;
607
616
expect ( allowed ) . to . be . true ;
608
617
} catch ( e ) {
609
- threwError = true ;
618
+ expect . fail ( e ) ;
610
619
}
611
- expect ( threwError ) . to . be . false ;
620
+
612
621
// clean up
613
622
await db . deletePush ( TEST_PUSH . id ) ;
614
623
await db . removeUserCanAuthorise ( repoName , TEST_USER . username ) ;
You can’t perform that action at this time.
0 commit comments