@@ -625,12 +625,12 @@ test.serial('Comment on issue/PR without ading a label', async (t) => {
625625 t . true ( github . isDone ( ) ) ;
626626} ) ;
627627
628- test . serial ( 'Editing the release to include all release links at the bottom' , async ( t ) => {
628+ test . serial ( 'Edit the release to include all the release links at the bottom by default ' , async ( t ) => {
629629 const owner = 'test_user' ;
630630 const repo = 'test_repo' ;
631631 const env = { GITHUB_TOKEN : 'github_token' } ;
632632 const failTitle = 'The automated release is failing 🚨' ;
633- const pluginConfig = { releasedLabels : false , addReleases : 'bottom' } ;
633+ const pluginConfig = { releasedLabels : false } ; // The addReleases is omitted
634634 const prs = [ { number : 1 , pull_request : { } , state : 'closed' } ] ;
635635 const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
636636 const nextRelease = { version : '2.0.0' , gitTag : 'v1.0.0' , name : 'v1.0.0' , notes : 'Test release note body' } ;
@@ -682,12 +682,64 @@ test.serial('Editing the release to include all release links at the bottom', as
682682 t . true ( github . isDone ( ) ) ;
683683} ) ;
684684
685- test . serial ( 'Editing the release to include all release links at the top ' , async ( t ) => {
685+ test . serial ( 'Edit the release to not include the release links' , async ( t ) => {
686686 const owner = 'test_user' ;
687687 const repo = 'test_repo' ;
688688 const env = { GITHUB_TOKEN : 'github_token' } ;
689689 const failTitle = 'The automated release is failing 🚨' ;
690- const pluginConfig = { releasedLabels : false , addReleases : 'top' } ;
690+ const pluginConfig = { releasedLabels : false , addReleases : false } ;
691+ const prs = [ { number : 1 , pull_request : { } , state : 'closed' } ] ;
692+ const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
693+ const nextRelease = { version : '2.0.0' , gitTag : 'v1.0.0' , name : 'v1.0.0' , notes : 'Test release note body' } ;
694+ const lastRelease = { version : '1.0.0' } ;
695+ const commits = [ { hash : '123' , message : 'Commit 1 message' } ] ;
696+ const releaseId = 1 ;
697+ const releases = [
698+ { name : 'GitHub release' , url : 'https://github.com/release' , id : releaseId } ,
699+ { name : 'S3' , url : 's3://my-bucket/release-asset' } ,
700+ { name : 'Docker: docker.io/python:slim' } ,
701+ ] ;
702+ const github = authenticate ( env )
703+ . get ( `/repos/${ owner } /${ repo } ` )
704+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
705+ . get (
706+ `/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
707+ . map ( ( commit ) => commit . hash )
708+ . join ( '+' ) } `
709+ )
710+ . reply ( 200 , { items : prs } )
711+ . get ( `/repos/${ owner } /${ repo } /pulls/1/commits` )
712+ . reply ( 200 , [ { sha : commits [ 0 ] . hash } ] )
713+ . post ( `/repos/${ owner } /${ repo } /issues/1/comments` , { body : / T h i s P R i s i n c l u d e d / } )
714+ . reply ( 200 , { html_url : 'https://github.com/successcomment-1' } )
715+ . get (
716+ `/search/issues?q=${ escape ( 'in:title' ) } +${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:issue' ) } +${ escape (
717+ 'state:open'
718+ ) } +${ escape ( failTitle ) } `
719+ )
720+ . reply ( 200 , { items : [ ] } ) ;
721+
722+ await success ( pluginConfig , {
723+ env,
724+ options,
725+ branch : { name : 'master' } ,
726+ lastRelease,
727+ commits,
728+ nextRelease,
729+ releases,
730+ logger : t . context . logger ,
731+ } ) ;
732+
733+ t . true ( t . context . log . calledWith ( 'Added comment to issue #%d: %s' , 1 , 'https://github.com/successcomment-1' ) ) ;
734+ t . true ( github . isDone ( ) ) ;
735+ } ) ;
736+
737+ test . serial ( 'Edit the release to include all the release links at the bottom' , async ( t ) => {
738+ const owner = 'test_user' ;
739+ const repo = 'test_repo' ;
740+ const env = { GITHUB_TOKEN : 'github_token' } ;
741+ const failTitle = 'The automated release is failing 🚨' ;
742+ const pluginConfig = { releasedLabels : false , addReleases : 'bottom' } ;
691743 const prs = [ { number : 1 , pull_request : { } , state : 'closed' } ] ;
692744 const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
693745 const nextRelease = { version : '2.0.0' , gitTag : 'v1.0.0' , name : 'v1.0.0' , notes : 'Test release note body' } ;
@@ -720,7 +772,7 @@ test.serial('Editing the release to include all release links at the top', async
720772 )
721773 . reply ( 200 , { items : [ ] } )
722774 . patch ( `/repos/${ owner } /${ repo } /releases/${ releaseId } ` , {
723- body : getReleaseLinks ( releases ) . concat ( '\n---\n' , nextRelease . notes ) ,
775+ body : nextRelease . notes . concat ( '\n---\n' , getReleaseLinks ( releases ) ) ,
724776 } )
725777 . reply ( 200 , { html_url : releaseUrl } ) ;
726778
@@ -739,7 +791,7 @@ test.serial('Editing the release to include all release links at the top', async
739791 t . true ( github . isDone ( ) ) ;
740792} ) ;
741793
742- test . serial ( 'Editing the release to include all release links with no additional releases ( top) ' , async ( t ) => {
794+ test . serial ( 'Edit the release to include all the release links at the top' , async ( t ) => {
743795 const owner = 'test_user' ;
744796 const repo = 'test_repo' ;
745797 const env = { GITHUB_TOKEN : 'github_token' } ;
@@ -750,8 +802,13 @@ test.serial('Editing the release to include all release links with no additional
750802 const nextRelease = { version : '2.0.0' , gitTag : 'v1.0.0' , name : 'v1.0.0' , notes : 'Test release note body' } ;
751803 const lastRelease = { version : '1.0.0' } ;
752804 const commits = [ { hash : '123' , message : 'Commit 1 message' } ] ;
805+ const releaseUrl = `https://github.com/${ owner } /${ repo } /releases/${ nextRelease . version } ` ;
753806 const releaseId = 1 ;
754- const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' , id : releaseId } ] ;
807+ const releases = [
808+ { name : 'GitHub release' , url : 'https://github.com/release' , id : releaseId } ,
809+ { name : 'S3' , url : 's3://my-bucket/release-asset' } ,
810+ { name : 'Docker: docker.io/python:slim' } ,
811+ ] ;
755812 const github = authenticate ( env )
756813 . get ( `/repos/${ owner } /${ repo } ` )
757814 . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
@@ -770,7 +827,11 @@ test.serial('Editing the release to include all release links with no additional
770827 'state:open'
771828 ) } +${ escape ( failTitle ) } `
772829 )
773- . reply ( 200 , { items : [ ] } ) ;
830+ . reply ( 200 , { items : [ ] } )
831+ . patch ( `/repos/${ owner } /${ repo } /releases/${ releaseId } ` , {
832+ body : getReleaseLinks ( releases ) . concat ( '\n---\n' , nextRelease . notes ) ,
833+ } )
834+ . reply ( 200 , { html_url : releaseUrl } ) ;
774835
775836 await success ( pluginConfig , {
776837 env,
@@ -787,12 +848,12 @@ test.serial('Editing the release to include all release links with no additional
787848 t . true ( github . isDone ( ) ) ;
788849} ) ;
789850
790- test . serial ( 'Editing the release to include all release links with no additional releases (bottom) ' , async ( t ) => {
851+ test . serial ( 'Edit the release to include all the release links at the top with no additional releases' , async ( t ) => {
791852 const owner = 'test_user' ;
792853 const repo = 'test_repo' ;
793854 const env = { GITHUB_TOKEN : 'github_token' } ;
794855 const failTitle = 'The automated release is failing 🚨' ;
795- const pluginConfig = { releasedLabels : false , addReleases : 'bottom ' } ;
856+ const pluginConfig = { releasedLabels : false , addReleases : 'top ' } ;
796857 const prs = [ { number : 1 , pull_request : { } , state : 'closed' } ] ;
797858 const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
798859 const nextRelease = { version : '2.0.0' , gitTag : 'v1.0.0' , name : 'v1.0.0' , notes : 'Test release note body' } ;
@@ -835,7 +896,58 @@ test.serial('Editing the release to include all release links with no additional
835896 t . true ( github . isDone ( ) ) ;
836897} ) ;
837898
838- test . serial ( 'Editing the release to include all release links with no releases' , async ( t ) => {
899+ test . serial (
900+ 'Edit the release to include all the release links at the bottom with no additional releases' ,
901+ async ( t ) => {
902+ const owner = 'test_user' ;
903+ const repo = 'test_repo' ;
904+ const env = { GITHUB_TOKEN : 'github_token' } ;
905+ const failTitle = 'The automated release is failing 🚨' ;
906+ const pluginConfig = { releasedLabels : false , addReleases : 'bottom' } ;
907+ const prs = [ { number : 1 , pull_request : { } , state : 'closed' } ] ;
908+ const options = { repositoryUrl : `https://github.com/${ owner } /${ repo } .git` } ;
909+ const nextRelease = { version : '2.0.0' , gitTag : 'v1.0.0' , name : 'v1.0.0' , notes : 'Test release note body' } ;
910+ const lastRelease = { version : '1.0.0' } ;
911+ const commits = [ { hash : '123' , message : 'Commit 1 message' } ] ;
912+ const releaseId = 1 ;
913+ const releases = [ { name : 'GitHub release' , url : 'https://github.com/release' , id : releaseId } ] ;
914+ const github = authenticate ( env )
915+ . get ( `/repos/${ owner } /${ repo } ` )
916+ . reply ( 200 , { full_name : `${ owner } /${ repo } ` } )
917+ . get (
918+ `/search/issues?q=${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:pr' ) } +${ escape ( 'is:merged' ) } +${ commits
919+ . map ( ( commit ) => commit . hash )
920+ . join ( '+' ) } `
921+ )
922+ . reply ( 200 , { items : prs } )
923+ . get ( `/repos/${ owner } /${ repo } /pulls/1/commits` )
924+ . reply ( 200 , [ { sha : commits [ 0 ] . hash } ] )
925+ . post ( `/repos/${ owner } /${ repo } /issues/1/comments` , { body : / T h i s P R i s i n c l u d e d / } )
926+ . reply ( 200 , { html_url : 'https://github.com/successcomment-1' } )
927+ . get (
928+ `/search/issues?q=${ escape ( 'in:title' ) } +${ escape ( `repo:${ owner } /${ repo } ` ) } +${ escape ( 'type:issue' ) } +${ escape (
929+ 'state:open'
930+ ) } +${ escape ( failTitle ) } `
931+ )
932+ . reply ( 200 , { items : [ ] } ) ;
933+
934+ await success ( pluginConfig , {
935+ env,
936+ options,
937+ branch : { name : 'master' } ,
938+ lastRelease,
939+ commits,
940+ nextRelease,
941+ releases,
942+ logger : t . context . logger ,
943+ } ) ;
944+
945+ t . true ( t . context . log . calledWith ( 'Added comment to issue #%d: %s' , 1 , 'https://github.com/successcomment-1' ) ) ;
946+ t . true ( github . isDone ( ) ) ;
947+ }
948+ ) ;
949+
950+ test . serial ( 'Edit the release to include all the release links with no releases' , async ( t ) => {
839951 const owner = 'test_user' ;
840952 const repo = 'test_repo' ;
841953 const env = { GITHUB_TOKEN : 'github_token' } ;
@@ -882,7 +994,7 @@ test.serial('Editing the release to include all release links with no releases',
882994 t . true ( github . isDone ( ) ) ;
883995} ) ;
884996
885- test . serial ( 'Editing the release with no ID in the release' , async ( t ) => {
997+ test . serial ( 'Edit the release to include all the release links with no ID in the release' , async ( t ) => {
886998 const owner = 'test_user' ;
887999 const repo = 'test_repo' ;
8881000 const env = { GITHUB_TOKEN : 'github_token' } ;
0 commit comments