File tree 2 files changed +18
-2
lines changed
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -58,10 +58,10 @@ export class WebhookEventDBImpl implements WebhookEventDB {
58
58
d . setDate ( d . getDate ( ) - ageInDays ) ;
59
59
const expirationDate = d . toISOString ( ) ;
60
60
const query = repo
61
- . createQueryBuilder ( "event" )
61
+ . createQueryBuilder ( )
62
62
. update ( )
63
63
. set ( { deleted : true } )
64
- . where ( "event. creationTime < :expirationDate" , { expirationDate } ) ;
64
+ . where ( "creationTime <= :expirationDate" , { expirationDate } ) ;
65
65
if ( typeof limit === "number" ) {
66
66
query . limit ( limit ) ;
67
67
}
Original file line number Diff line number Diff line change @@ -52,6 +52,22 @@ export class WebhookEventDBSpec {
52
52
expect ( updated . type , "type should not be updated" ) . to . equal ( "push" ) ;
53
53
expect ( updated . rawEvent , "rawEvent should not be updated" ) . to . equal ( "payload as string" ) ;
54
54
}
55
+
56
+ @test public async testDeleteOldEvents ( ) {
57
+ const cloneUrl = "http://gitlab.local/project/repo" ;
58
+ await this . db . createEvent ( {
59
+ rawEvent : "payload as string" ,
60
+ status : "received" ,
61
+ type : "push" ,
62
+ cloneUrl,
63
+ } ) ;
64
+
65
+ await this . db . deleteOldEvents ( 0 , 1 ) ;
66
+
67
+ const event = ( await this . db . findByCloneUrl ( cloneUrl ) ) [ 0 ] ;
68
+ expect ( event , "should be found" ) . to . be . not . undefined ;
69
+ expect ( ( event as DBWebhookEvent ) . deleted , "should be marked as deleted" ) . to . be . true ;
70
+ }
55
71
}
56
72
57
73
module . exports = WebhookEventDBSpec ;
You can’t perform that action at this time.
0 commit comments