@@ -38,21 +38,21 @@ func TestActionsArtifactUploadSingleFile(t *testing.T) {
3838
3939 // get upload url
4040 idx := strings .Index (uploadResp .FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/" )
41- url := uploadResp .FileContainerResourceURL [idx :] + "?itemPath=artifact/abc.txt"
41+ url := uploadResp .FileContainerResourceURL [idx :] + "?itemPath=artifact/abc-2 .txt"
4242
4343 // upload artifact chunk
44- body := strings .Repeat ("A " , 1024 )
44+ body := strings .Repeat ("C " , 1024 )
4545 req = NewRequestWithBody (t , "PUT" , url , strings .NewReader (body )).
4646 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" ).
4747 SetHeader ("Content-Range" , "bytes 0-1023/1024" ).
4848 SetHeader ("x-tfs-filelength" , "1024" ).
49- SetHeader ("x-actions-results-md5" , "1HsSe8LeLWh93ILaw1TEFQ ==" ) // base64(md5(body))
49+ SetHeader ("x-actions-results-md5" , "XVlf820rMInUi64wmMi6EA ==" ) // base64(md5(body))
5050 MakeRequest (t , req , http .StatusOK )
5151
5252 t .Logf ("Create artifact confirm" )
5353
5454 // confirm artifact upload
55- req = NewRequest (t , "PATCH" , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts?artifactName=artifact" ).
55+ req = NewRequest (t , "PATCH" , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts?artifactName=artifact-single " ).
5656 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
5757 MakeRequest (t , req , http .StatusOK )
5858}
@@ -115,29 +115,40 @@ func TestActionsArtifactDownload(t *testing.T) {
115115 resp := MakeRequest (t , req , http .StatusOK )
116116 var listResp listArtifactsResponse
117117 DecodeJSON (t , resp , & listResp )
118- assert .Equal (t , int64 (1 ), listResp .Count )
119- assert .Equal (t , "artifact" , listResp .Value [0 ].Name )
120- assert .Contains (t , listResp .Value [0 ].FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" )
118+ assert .Equal (t , int64 (2 ), listResp .Count )
119+
120+ // Return list might be in any order. Get one file.
121+ var artifactIdx int
122+ for i , artifact := range listResp .Value {
123+ if artifact .Name == "artifact-download" {
124+ artifactIdx = i
125+ break
126+ }
127+ }
128+ assert .NotNil (t , artifactIdx )
129+ assert .Equal (t , listResp .Value [artifactIdx ].Name , "artifact-download" )
130+ assert .Contains (t , listResp .Value [artifactIdx ].FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" )
121131
122- idx := strings .Index (listResp .Value [0 ].FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/" )
123- url := listResp .Value [0 ].FileContainerResourceURL [idx + 1 :] + "?itemPath=artifact"
132+ idx := strings .Index (listResp .Value [artifactIdx ].FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/" )
133+ url := listResp .Value [artifactIdx ].FileContainerResourceURL [idx + 1 :] + "?itemPath=artifact-download "
124134 req = NewRequest (t , "GET" , url ).
125135 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
126136 resp = MakeRequest (t , req , http .StatusOK )
127137 var downloadResp downloadArtifactResponse
128138 DecodeJSON (t , resp , & downloadResp )
129139 assert .Len (t , downloadResp .Value , 1 )
130- assert .Equal (t , "artifact/abc.txt" , downloadResp .Value [0 ].Path )
131- assert .Equal (t , "file" , downloadResp .Value [0 ].ItemType )
132- assert .Contains (t , downloadResp .Value [0 ].ContentLocation , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" )
140+ assert .Equal (t , "artifact-download /abc.txt" , downloadResp .Value [artifactIdx ].Path )
141+ assert .Equal (t , "file" , downloadResp .Value [artifactIdx ].ItemType )
142+ assert .Contains (t , downloadResp .Value [artifactIdx ].ContentLocation , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" )
133143
134- idx = strings .Index (downloadResp .Value [0 ].ContentLocation , "/api/actions_pipeline/_apis/pipelines/" )
135- url = downloadResp .Value [0 ].ContentLocation [idx :]
144+ idx = strings .Index (downloadResp .Value [artifactIdx ].ContentLocation , "/api/actions_pipeline/_apis/pipelines/" )
145+ url = downloadResp .Value [artifactIdx ].ContentLocation [idx :]
136146 req = NewRequest (t , "GET" , url ).
137147 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
138148 resp = MakeRequest (t , req , http .StatusOK )
149+
139150 body := strings .Repeat ("A" , 1024 )
140- assert .Equal (t , resp .Body .String (), body )
151+ assert .Equal (t , body , resp .Body .String ())
141152}
142153
143154func TestActionsArtifactUploadMultipleFile (t * testing.T ) {
@@ -163,14 +174,14 @@ func TestActionsArtifactUploadMultipleFile(t *testing.T) {
163174
164175 files := []uploadingFile {
165176 {
166- Path : "abc.txt" ,
167- Content : strings .Repeat ("A " , 1024 ),
168- MD5 : "1HsSe8LeLWh93ILaw1TEFQ ==" ,
177+ Path : "abc-3 .txt" ,
178+ Content : strings .Repeat ("D " , 1024 ),
179+ MD5 : "9nqj7E8HZmfQtPifCJ5Zww ==" ,
169180 },
170181 {
171- Path : "xyz/def.txt" ,
172- Content : strings .Repeat ("B " , 1024 ),
173- MD5 : "6fgADK/7zjadf+6cB9Q1CQ ==" ,
182+ Path : "xyz/def-2 .txt" ,
183+ Content : strings .Repeat ("E " , 1024 ),
184+ MD5 : "/s1kKvxeHlUX85vaTaVxuA ==" ,
174185 },
175186 }
176187
@@ -199,7 +210,7 @@ func TestActionsArtifactUploadMultipleFile(t *testing.T) {
199210func TestActionsArtifactDownloadMultiFiles (t * testing.T ) {
200211 defer tests .PrepareTestEnv (t )()
201212
202- const testArtifactName = "multi-files "
213+ const testArtifactName = "multi-file-download "
203214
204215 req := NewRequest (t , "GET" , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" ).
205216 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
@@ -226,7 +237,7 @@ func TestActionsArtifactDownloadMultiFiles(t *testing.T) {
226237 DecodeJSON (t , resp , & downloadResp )
227238 assert .Len (t , downloadResp .Value , 2 )
228239
229- downloads := [][]string {{"multi-files /abc.txt" , "A " }, {"multi-files /xyz/def.txt" , "B " }}
240+ downloads := [][]string {{"multi-file-download /abc.txt" , "B " }, {"multi-file-download /xyz/def.txt" , "C " }}
230241 for _ , v := range downloadResp .Value {
231242 var bodyChar string
232243 var path string
@@ -247,8 +258,7 @@ func TestActionsArtifactDownloadMultiFiles(t *testing.T) {
247258 req = NewRequest (t , "GET" , url ).
248259 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
249260 resp = MakeRequest (t , req , http .StatusOK )
250- body := strings .Repeat (bodyChar , 1024 )
251- assert .Equal (t , resp .Body .String (), body )
261+ assert .Equal (t , strings .Repeat (bodyChar , 1024 ), resp .Body .String ())
252262 }
253263}
254264
@@ -300,7 +310,7 @@ func TestActionsArtifactOverwrite(t *testing.T) {
300310 DecodeJSON (t , resp , & listResp )
301311
302312 idx := strings .Index (listResp .Value [0 ].FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/" )
303- url := listResp .Value [0 ].FileContainerResourceURL [idx + 1 :] + "?itemPath=artifact"
313+ url := listResp .Value [0 ].FileContainerResourceURL [idx + 1 :] + "?itemPath=artifact-download "
304314 req = NewRequest (t , "GET" , url ).
305315 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
306316 resp = MakeRequest (t , req , http .StatusOK )
@@ -320,14 +330,14 @@ func TestActionsArtifactOverwrite(t *testing.T) {
320330 // upload same artifact, it uses 4096 B
321331 req := NewRequestWithJSON (t , "POST" , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" , getUploadArtifactRequest {
322332 Type : "actions_storage" ,
323- Name : "artifact" ,
333+ Name : "artifact-download " ,
324334 }).AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
325335 resp := MakeRequest (t , req , http .StatusOK )
326336 var uploadResp uploadArtifactResponse
327337 DecodeJSON (t , resp , & uploadResp )
328338
329339 idx := strings .Index (uploadResp .FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/" )
330- url := uploadResp .FileContainerResourceURL [idx :] + "?itemPath=artifact/abc.txt"
340+ url := uploadResp .FileContainerResourceURL [idx :] + "?itemPath=artifact-download /abc.txt"
331341 body := strings .Repeat ("B" , 4096 )
332342 req = NewRequestWithBody (t , "PUT" , url , strings .NewReader (body )).
333343 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" ).
@@ -337,7 +347,7 @@ func TestActionsArtifactOverwrite(t *testing.T) {
337347 MakeRequest (t , req , http .StatusOK )
338348
339349 // confirm artifact upload
340- req = NewRequest (t , "PATCH" , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts?artifactName=artifact" ).
350+ req = NewRequest (t , "PATCH" , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts?artifactName=artifact-download " ).
341351 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
342352 MakeRequest (t , req , http .StatusOK )
343353 }
@@ -352,15 +362,15 @@ func TestActionsArtifactOverwrite(t *testing.T) {
352362
353363 var uploadedItem listArtifactsResponseItem
354364 for _ , item := range listResp .Value {
355- if item .Name == "artifact" {
365+ if item .Name == "artifact-download " {
356366 uploadedItem = item
357367 break
358368 }
359369 }
360- assert .Equal (t , uploadedItem .Name , "artifact" )
370+ assert .Equal (t , uploadedItem .Name , "artifact-download " )
361371
362372 idx := strings .Index (uploadedItem .FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/" )
363- url := uploadedItem .FileContainerResourceURL [idx + 1 :] + "?itemPath=artifact"
373+ url := uploadedItem .FileContainerResourceURL [idx + 1 :] + "?itemPath=artifact-download "
364374 req = NewRequest (t , "GET" , url ).
365375 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
366376 resp = MakeRequest (t , req , http .StatusOK )
0 commit comments