@@ -447,18 +447,23 @@ test.serial('Do not add comment and labels to PR/issues from other repo', async
447
447
t . true ( github . isDone ( ) ) ;
448
448
} ) ;
449
449
450
- test . serial ( 'Ignore missing issues/PRs' , async t => {
450
+ test . serial ( 'Ignore missing and forbidden issues/PRs' , async t => {
451
451
const owner = 'test_user' ;
452
452
const repo = 'test_repo' ;
453
453
const env = { GITHUB_TOKEN : 'github_token' } ;
454
454
const failTitle = 'The automated release is failing 🚨' ;
455
455
const pluginConfig = { failTitle} ;
456
456
const prs = [
457
457
{ number : 1 , pull_request : { } , state : 'closed' } ,
458
- { number : 2 , pull_request : { } , body : 'Fixes #3' , state : 'closed' } ,
458
+ { number : 2 , pull_request : { } , body : 'Fixes #4' , state : 'closed' } ,
459
+ { number : 3 , pull_request : { } , body : 'Fixes #5' , state : 'closed' } ,
459
460
] ;
460
461
const options = { branch : 'master' , repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
461
- const commits = [ { hash : '123' , message : 'Commit 1 message\n\n Fix #1' } , { hash : '456' , message : 'Commit 2 message' } ] ;
462
+ const commits = [
463
+ { hash : '123' , message : 'Commit 1 message\n\n Fix #1' } ,
464
+ { hash : '456' , message : 'Commit 2 message' } ,
465
+ { hash : '789' , message : 'Commit 3 message' } ,
466
+ ] ;
462
467
const nextRelease = { version : '1.0.0' } ;
463
468
const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
464
469
const github = authenticate ( env )
@@ -474,18 +479,28 @@ test.serial('Ignore missing issues/PRs', async t => {
474
479
. reply ( 200 , [ { sha : commits [ 0 ] . hash } ] )
475
480
. get ( `/repos/${ owner } /${ repo } /pulls/2/commits` )
476
481
. reply ( 200 , [ { sha : commits [ 1 ] . hash } ] )
482
+ . get ( `/repos/${ owner } /${ repo } /pulls/3/commits` )
483
+ . reply ( 200 , [ { sha : commits [ 2 ] . hash } ] )
477
484
. post ( `/repos/${ owner } /${ repo } /issues/1/comments` , { body : / T h i s P R i s i n c l u d e d / } )
478
485
. reply ( 200 , { html_url : 'https://github.com/successcomment-1' } )
479
486
. post ( `/repos/${ owner } /${ repo } /issues/1/labels` , '["released"]' )
480
487
. reply ( 200 , { } )
481
488
. post ( `/repos/${ owner } /${ repo } /issues/2/comments` , { body : / T h i s P R i s i n c l u d e d / } )
482
489
. times ( 3 )
483
490
. reply ( 404 )
484
- . get ( `/repos/${ owner } /${ repo } /issues/3` )
491
+ . post ( `/repos/${ owner } /${ repo } /issues/3/comments` , { body : / T h i s P R i s i n c l u d e d / } )
492
+ . reply ( 403 )
493
+ . get ( `/repos/${ owner } /${ repo } /issues/4` )
485
494
. reply ( 200 , { state : 'closed' } )
486
- . post ( `/repos/${ owner } /${ repo } /issues/3/comments` , { body : / T h i s i s s u e h a s b e e n r e s o l v e d / } )
487
- . reply ( 200 , { html_url : 'https://github.com/successcomment-3' } )
488
- . post ( `/repos/${ owner } /${ repo } /issues/3/labels` , '["released"]' )
495
+ . get ( `/repos/${ owner } /${ repo } /issues/5` )
496
+ . reply ( 200 , { state : 'closed' } )
497
+ . post ( `/repos/${ owner } /${ repo } /issues/4/comments` , { body : / T h i s i s s u e h a s b e e n r e s o l v e d / } )
498
+ . reply ( 200 , { html_url : 'https://github.com/successcomment-4' } )
499
+ . post ( `/repos/${ owner } /${ repo } /issues/4/labels` , '["released"]' )
500
+ . reply ( 200 , { } )
501
+ . post ( `/repos/${ owner } /${ repo } /issues/5/comments` , { body : / T h i s i s s u e h a s b e e n r e s o l v e d / } )
502
+ . reply ( 200 , { html_url : 'https://github.com/successcomment-5' } )
503
+ . post ( `/repos/${ owner } /${ repo } /issues/5/labels` , '["released"]' )
489
504
. reply ( 200 , { } )
490
505
. get (
491
506
`/search/issues?q=${ escape ( 'in:title' ) } +${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:issue' ) } +${ escape (
@@ -498,9 +513,12 @@ test.serial('Ignore missing issues/PRs', async t => {
498
513
499
514
t . true ( t . context . log . calledWith ( 'Added comment to issue #%d: %s' , 1 , 'https://github.com/successcomment-1' ) ) ;
500
515
t . true ( t . context . log . calledWith ( 'Added labels %O to issue #%d' , [ 'released' ] , 1 ) ) ;
501
- t . true ( t . context . log . calledWith ( 'Added comment to issue #%d: %s' , 3 , 'https://github.com/successcomment-3' ) ) ;
502
- t . true ( t . context . log . calledWith ( 'Added labels %O to issue #%d' , [ 'released' ] , 3 ) ) ;
516
+ t . true ( t . context . log . calledWith ( 'Added comment to issue #%d: %s' , 4 , 'https://github.com/successcomment-4' ) ) ;
517
+ t . true ( t . context . log . calledWith ( 'Added labels %O to issue #%d' , [ 'released' ] , 4 ) ) ;
518
+ t . true ( t . context . log . calledWith ( 'Added comment to issue #%d: %s' , 5 , 'https://github.com/successcomment-5' ) ) ;
519
+ t . true ( t . context . log . calledWith ( 'Added labels %O to issue #%d' , [ 'released' ] , 5 ) ) ;
503
520
t . true ( t . context . error . calledWith ( "Failed to add a comment to the issue #%d as it doesn't exist." , 2 ) ) ;
521
+ t . true ( t . context . error . calledWith ( 'Not allowed to add a comment to the issue #%d.' , 3 ) ) ;
504
522
t . true ( github . isDone ( ) ) ;
505
523
} ) ;
506
524
0 commit comments