@@ -447,18 +447,23 @@ test.serial('Do not add comment and labels to PR/issues from other repo', async
447447 t . true ( github . isDone ( ) ) ;
448448} ) ;
449449
450- test . serial ( 'Ignore missing issues/PRs' , async t => {
450+ test . serial ( 'Ignore missing and forbidden issues/PRs' , async t => {
451451 const owner = 'test_user' ;
452452 const repo = 'test_repo' ;
453453 const env = { GITHUB_TOKEN : 'github_token' } ;
454454 const failTitle = 'The automated release is failing 🚨' ;
455455 const pluginConfig = { failTitle} ;
456456 const prs = [
457457 { 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' } ,
459460 ] ;
460461 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+ ] ;
462467 const nextRelease = { version : '1.0.0' } ;
463468 const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' } ] ;
464469 const github = authenticate ( env )
@@ -474,18 +479,28 @@ test.serial('Ignore missing issues/PRs', async t => {
474479 . reply ( 200 , [ { sha : commits [ 0 ] . hash } ] )
475480 . get ( `/repos/${ owner } /${ repo } /pulls/2/commits` )
476481 . reply ( 200 , [ { sha : commits [ 1 ] . hash } ] )
482+ . get ( `/repos/${ owner } /${ repo } /pulls/3/commits` )
483+ . reply ( 200 , [ { sha : commits [ 2 ] . hash } ] )
477484 . post ( `/repos/${ owner } /${ repo } /issues/1/comments` , { body : / T h i s P R i s i n c l u d e d / } )
478485 . reply ( 200 , { html_url : 'https://github.com/successcomment-1' } )
479486 . post ( `/repos/${ owner } /${ repo } /issues/1/labels` , '["released"]' )
480487 . reply ( 200 , { } )
481488 . post ( `/repos/${ owner } /${ repo } /issues/2/comments` , { body : / T h i s P R i s i n c l u d e d / } )
482489 . times ( 3 )
483490 . 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` )
485494 . 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"]' )
489504 . reply ( 200 , { } )
490505 . get (
491506 `/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 => {
498513
499514 t . true ( t . context . log . calledWith ( 'Added comment to issue #%d: %s' , 1 , 'https://github.com/successcomment-1' ) ) ;
500515 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 ) ) ;
503520 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 ) ) ;
504522 t . true ( github . isDone ( ) ) ;
505523} ) ;
506524
0 commit comments