@@ -38,21 +38,21 @@ func TestActionsArtifactUploadSingleFile(t *testing.T) {
38
38
39
39
// get upload url
40
40
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"
42
42
43
43
// upload artifact chunk
44
- body := strings .Repeat ("A " , 1024 )
44
+ body := strings .Repeat ("C " , 1024 )
45
45
req = NewRequestWithBody (t , "PUT" , url , strings .NewReader (body )).
46
46
AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" ).
47
47
SetHeader ("Content-Range" , "bytes 0-1023/1024" ).
48
48
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))
50
50
MakeRequest (t , req , http .StatusOK )
51
51
52
52
t .Logf ("Create artifact confirm" )
53
53
54
54
// 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 " ).
56
56
AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
57
57
MakeRequest (t , req , http .StatusOK )
58
58
}
@@ -115,29 +115,40 @@ func TestActionsArtifactDownload(t *testing.T) {
115
115
resp := MakeRequest (t , req , http .StatusOK )
116
116
var listResp listArtifactsResponse
117
117
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" )
121
131
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 "
124
134
req = NewRequest (t , "GET" , url ).
125
135
AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
126
136
resp = MakeRequest (t , req , http .StatusOK )
127
137
var downloadResp downloadArtifactResponse
128
138
DecodeJSON (t , resp , & downloadResp )
129
139
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" )
133
143
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 :]
136
146
req = NewRequest (t , "GET" , url ).
137
147
AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
138
148
resp = MakeRequest (t , req , http .StatusOK )
149
+
139
150
body := strings .Repeat ("A" , 1024 )
140
- assert .Equal (t , resp .Body .String (), body )
151
+ assert .Equal (t , body , resp .Body .String ())
141
152
}
142
153
143
154
func TestActionsArtifactUploadMultipleFile (t * testing.T ) {
@@ -163,14 +174,14 @@ func TestActionsArtifactUploadMultipleFile(t *testing.T) {
163
174
164
175
files := []uploadingFile {
165
176
{
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 ==" ,
169
180
},
170
181
{
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 ==" ,
174
185
},
175
186
}
176
187
@@ -199,7 +210,7 @@ func TestActionsArtifactUploadMultipleFile(t *testing.T) {
199
210
func TestActionsArtifactDownloadMultiFiles (t * testing.T ) {
200
211
defer tests .PrepareTestEnv (t )()
201
212
202
- const testArtifactName = "multi-files "
213
+ const testArtifactName = "multi-file-download "
203
214
204
215
req := NewRequest (t , "GET" , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" ).
205
216
AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
@@ -226,7 +237,7 @@ func TestActionsArtifactDownloadMultiFiles(t *testing.T) {
226
237
DecodeJSON (t , resp , & downloadResp )
227
238
assert .Len (t , downloadResp .Value , 2 )
228
239
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 " }}
230
241
for _ , v := range downloadResp .Value {
231
242
var bodyChar string
232
243
var path string
@@ -247,8 +258,7 @@ func TestActionsArtifactDownloadMultiFiles(t *testing.T) {
247
258
req = NewRequest (t , "GET" , url ).
248
259
AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
249
260
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 ())
252
262
}
253
263
}
254
264
@@ -300,7 +310,7 @@ func TestActionsArtifactOverwrite(t *testing.T) {
300
310
DecodeJSON (t , resp , & listResp )
301
311
302
312
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 "
304
314
req = NewRequest (t , "GET" , url ).
305
315
AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
306
316
resp = MakeRequest (t , req , http .StatusOK )
@@ -320,14 +330,14 @@ func TestActionsArtifactOverwrite(t *testing.T) {
320
330
// upload same artifact, it uses 4096 B
321
331
req := NewRequestWithJSON (t , "POST" , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" , getUploadArtifactRequest {
322
332
Type : "actions_storage" ,
323
- Name : "artifact" ,
333
+ Name : "artifact-download " ,
324
334
}).AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
325
335
resp := MakeRequest (t , req , http .StatusOK )
326
336
var uploadResp uploadArtifactResponse
327
337
DecodeJSON (t , resp , & uploadResp )
328
338
329
339
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"
331
341
body := strings .Repeat ("B" , 4096 )
332
342
req = NewRequestWithBody (t , "PUT" , url , strings .NewReader (body )).
333
343
AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" ).
@@ -337,7 +347,7 @@ func TestActionsArtifactOverwrite(t *testing.T) {
337
347
MakeRequest (t , req , http .StatusOK )
338
348
339
349
// 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 " ).
341
351
AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
342
352
MakeRequest (t , req , http .StatusOK )
343
353
}
@@ -352,15 +362,15 @@ func TestActionsArtifactOverwrite(t *testing.T) {
352
362
353
363
var uploadedItem listArtifactsResponseItem
354
364
for _ , item := range listResp .Value {
355
- if item .Name == "artifact" {
365
+ if item .Name == "artifact-download " {
356
366
uploadedItem = item
357
367
break
358
368
}
359
369
}
360
- assert .Equal (t , uploadedItem .Name , "artifact" )
370
+ assert .Equal (t , uploadedItem .Name , "artifact-download " )
361
371
362
372
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 "
364
374
req = NewRequest (t , "GET" , url ).
365
375
AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
366
376
resp = MakeRequest (t , req , http .StatusOK )
0 commit comments