@@ -83,7 +83,7 @@ test.serial("Publish a release with assets", async (t) => {
8383 t . true ( gitlab . isDone ( ) ) ;
8484} ) ;
8585
86- test . serial ( "Publish a release with generics" , async ( t ) => {
86+ test . serial ( "Publish a release with generics and relative URL " , async ( t ) => {
8787 const cwd = "test/fixtures/files" ;
8888 const owner = "test_user" ;
8989 const repo = "test_repo" ;
@@ -96,6 +96,138 @@ test.serial("Publish a release with generics", async (t) => {
9696 const generic = { path : "file.css" , label : "Style package" , target : "generic_package" , status : "hidden" } ;
9797 const assets = [ generic ] ;
9898 const encodedLabel = encodeURIComponent ( generic . label ) ;
99+ const gitlab = authenticate ( env )
100+ . post ( `/projects/${ encodedRepoId } /releases` , {
101+ tag_name : nextRelease . gitTag ,
102+ description : nextRelease . notes ,
103+ assets : {
104+ links : [
105+ {
106+ name : "Style package" ,
107+ url : `https://gitlab.com/${ owner } /${ repo } ${ uploaded . file . url } ` ,
108+ link_type : "package" ,
109+ } ,
110+ ] ,
111+ } ,
112+ } )
113+ . reply ( 200 ) ;
114+ const gitlabUpload = authenticate ( env )
115+ . put (
116+ `/projects/${ encodedRepoId } /packages/generic/release/${ encodedGitTag } /${ encodedLabel } ?status=${ generic . status } &select=package_file` ,
117+ / \. t e s t \s \{ \} / gm
118+ )
119+ . reply ( 200 , uploaded ) ;
120+
121+ const result = await publish ( { assets } , { env, cwd, options, nextRelease, logger : t . context . logger } ) ;
122+
123+ t . is ( result . url , `https://gitlab.com/${ owner } /${ repo } /-/releases/${ encodedGitTag } ` ) ;
124+ t . deepEqual ( t . context . log . args [ 0 ] , [ "Uploaded file: %s" , uploaded . file . url ] ) ;
125+ t . deepEqual ( t . context . log . args [ 1 ] , [ "Published GitLab release: %s" , nextRelease . gitTag ] ) ;
126+ t . true ( gitlabUpload . isDone ( ) ) ;
127+ t . true ( gitlab . isDone ( ) ) ;
128+ } ) ;
129+
130+ test . serial ( "Publish a release with generics and external storage provider (http)" , async ( t ) => {
131+ const cwd = "test/fixtures/files" ;
132+ const owner = "test_user" ;
133+ const repo = "test_repo" ;
134+ const env = { GITLAB_TOKEN : "gitlab_token" } ;
135+ const nextRelease = { gitHead : "123" , gitTag : "v1.0.0" , notes : "Test release note body" } ;
136+ const options = { repositoryUrl : `https://gitlab.com/${ owner } /${ repo } .git` } ;
137+ const encodedRepoId = encodeURIComponent ( `${ owner } /${ repo } ` ) ;
138+ const encodedGitTag = encodeURIComponent ( nextRelease . gitTag ) ;
139+ const uploaded = { file : { url : "http://aws.example.com/bucket/gitlab/file.css" } } ;
140+ const generic = { path : "file.css" , label : "Style package" , target : "generic_package" , status : "hidden" } ;
141+ const assets = [ generic ] ;
142+ const encodedLabel = encodeURIComponent ( generic . label ) ;
143+ const gitlab = authenticate ( env )
144+ . post ( `/projects/${ encodedRepoId } /releases` , {
145+ tag_name : nextRelease . gitTag ,
146+ description : nextRelease . notes ,
147+ assets : {
148+ links : [
149+ {
150+ name : "Style package" ,
151+ url : uploaded . file . url ,
152+ link_type : "package" ,
153+ } ,
154+ ] ,
155+ } ,
156+ } )
157+ . reply ( 200 ) ;
158+ const gitlabUpload = authenticate ( env )
159+ . put (
160+ `/projects/${ encodedRepoId } /packages/generic/release/${ encodedGitTag } /${ encodedLabel } ?status=${ generic . status } &select=package_file` ,
161+ / \. t e s t \s \{ \} / gm
162+ )
163+ . reply ( 200 , uploaded ) ;
164+
165+ const result = await publish ( { assets } , { env, cwd, options, nextRelease, logger : t . context . logger } ) ;
166+
167+ t . is ( result . url , `https://gitlab.com/${ owner } /${ repo } /-/releases/${ encodedGitTag } ` ) ;
168+ t . deepEqual ( t . context . log . args [ 0 ] , [ "Uploaded file: %s" , uploaded . file . url ] ) ;
169+ t . deepEqual ( t . context . log . args [ 1 ] , [ "Published GitLab release: %s" , nextRelease . gitTag ] ) ;
170+ t . true ( gitlabUpload . isDone ( ) ) ;
171+ t . true ( gitlab . isDone ( ) ) ;
172+ } ) ;
173+
174+ test . serial ( "Publish a release with generics and external storage provider (https)" , async ( t ) => {
175+ const cwd = "test/fixtures/files" ;
176+ const owner = "test_user" ;
177+ const repo = "test_repo" ;
178+ const env = { GITLAB_TOKEN : "gitlab_token" } ;
179+ const nextRelease = { gitHead : "123" , gitTag : "v1.0.0" , notes : "Test release note body" } ;
180+ const options = { repositoryUrl : `https://gitlab.com/${ owner } /${ repo } .git` } ;
181+ const encodedRepoId = encodeURIComponent ( `${ owner } /${ repo } ` ) ;
182+ const encodedGitTag = encodeURIComponent ( nextRelease . gitTag ) ;
183+ const uploaded = { file : { url : "https://aws.example.com/bucket/gitlab/file.css" } } ;
184+ const generic = { path : "file.css" , label : "Style package" , target : "generic_package" , status : "hidden" } ;
185+ const assets = [ generic ] ;
186+ const encodedLabel = encodeURIComponent ( generic . label ) ;
187+ const gitlab = authenticate ( env )
188+ . post ( `/projects/${ encodedRepoId } /releases` , {
189+ tag_name : nextRelease . gitTag ,
190+ description : nextRelease . notes ,
191+ assets : {
192+ links : [
193+ {
194+ name : "Style package" ,
195+ url : uploaded . file . url ,
196+ link_type : "package" ,
197+ } ,
198+ ] ,
199+ } ,
200+ } )
201+ . reply ( 200 ) ;
202+ const gitlabUpload = authenticate ( env )
203+ . put (
204+ `/projects/${ encodedRepoId } /packages/generic/release/${ encodedGitTag } /${ encodedLabel } ?status=${ generic . status } &select=package_file` ,
205+ / \. t e s t \s \{ \} / gm
206+ )
207+ . reply ( 200 , uploaded ) ;
208+
209+ const result = await publish ( { assets } , { env, cwd, options, nextRelease, logger : t . context . logger } ) ;
210+
211+ t . is ( result . url , `https://gitlab.com/${ owner } /${ repo } /-/releases/${ encodedGitTag } ` ) ;
212+ t . deepEqual ( t . context . log . args [ 0 ] , [ "Uploaded file: %s" , uploaded . file . url ] ) ;
213+ t . deepEqual ( t . context . log . args [ 1 ] , [ "Published GitLab release: %s" , nextRelease . gitTag ] ) ;
214+ t . true ( gitlabUpload . isDone ( ) ) ;
215+ t . true ( gitlab . isDone ( ) ) ;
216+ } ) ;
217+
218+ test . serial ( "Publish a release with generics and external storage provider (ftp)" , async ( t ) => {
219+ const cwd = "test/fixtures/files" ;
220+ const owner = "test_user" ;
221+ const repo = "test_repo" ;
222+ const env = { GITLAB_TOKEN : "gitlab_token" } ;
223+ const nextRelease = { gitHead : "123" , gitTag : "v1.0.0" , notes : "Test release note body" } ;
224+ const options = { repositoryUrl : `https://gitlab.com/${ owner } /${ repo } .git` } ;
225+ const encodedRepoId = encodeURIComponent ( `${ owner } /${ repo } ` ) ;
226+ const encodedGitTag = encodeURIComponent ( nextRelease . gitTag ) ;
227+ const uploaded = { file : { url : "ftp://drive.example.com/gitlab/file.css" } } ;
228+ const generic = { path : "file.css" , label : "Style package" , target : "generic_package" , status : "hidden" } ;
229+ const assets = [ generic ] ;
230+ const encodedLabel = encodeURIComponent ( generic . label ) ;
99231 const gitlab = authenticate ( env )
100232 . post ( `/projects/${ encodedRepoId } /releases` , {
101233 tag_name : nextRelease . gitTag ,
0 commit comments