@@ -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,19 +115,19 @@ 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 )
118
+ assert .Equal (t , int64 (2 ), listResp .Count )
119
+ assert .Equal (t , "artifact-download " , listResp .Value [0 ].Name )
120
120
assert .Contains (t , listResp .Value [0 ].FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" )
121
121
122
122
idx := strings .Index (listResp .Value [0 ].FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/" )
123
- url := listResp .Value [0 ].FileContainerResourceURL [idx + 1 :] + "?itemPath=artifact"
123
+ url := listResp .Value [0 ].FileContainerResourceURL [idx + 1 :] + "?itemPath=artifact-download "
124
124
req = NewRequest (t , "GET" , url ).
125
125
AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
126
126
resp = MakeRequest (t , req , http .StatusOK )
127
127
var downloadResp downloadArtifactResponse
128
128
DecodeJSON (t , resp , & downloadResp )
129
129
assert .Len (t , downloadResp .Value , 1 )
130
- assert .Equal (t , "artifact/abc.txt" , downloadResp .Value [0 ].Path )
130
+ assert .Equal (t , "artifact-download /abc.txt" , downloadResp .Value [0 ].Path )
131
131
assert .Equal (t , "file" , downloadResp .Value [0 ].ItemType )
132
132
assert .Contains (t , downloadResp .Value [0 ].ContentLocation , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" )
133
133
@@ -136,8 +136,9 @@ func TestActionsArtifactDownload(t *testing.T) {
136
136
req = NewRequest (t , "GET" , url ).
137
137
AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
138
138
resp = MakeRequest (t , req , http .StatusOK )
139
+
139
140
body := strings .Repeat ("A" , 1024 )
140
- assert .Equal (t , resp .Body .String (), body )
141
+ assert .Equal (t , body , resp .Body .String ())
141
142
}
142
143
143
144
func TestActionsArtifactUploadMultipleFile (t * testing.T ) {
@@ -163,14 +164,14 @@ func TestActionsArtifactUploadMultipleFile(t *testing.T) {
163
164
164
165
files := []uploadingFile {
165
166
{
166
- Path : "abc.txt" ,
167
- Content : strings .Repeat ("A " , 1024 ),
168
- MD5 : "1HsSe8LeLWh93ILaw1TEFQ ==" ,
167
+ Path : "abc-3 .txt" ,
168
+ Content : strings .Repeat ("D " , 1024 ),
169
+ MD5 : "9nqj7E8HZmfQtPifCJ5Zww ==" ,
169
170
},
170
171
{
171
- Path : "xyz/def.txt" ,
172
- Content : strings .Repeat ("B " , 1024 ),
173
- MD5 : "6fgADK/7zjadf+6cB9Q1CQ ==" ,
172
+ Path : "xyz/def-2 .txt" ,
173
+ Content : strings .Repeat ("E " , 1024 ),
174
+ MD5 : "/s1kKvxeHlUX85vaTaVxuA ==" ,
174
175
},
175
176
}
176
177
@@ -199,7 +200,7 @@ func TestActionsArtifactUploadMultipleFile(t *testing.T) {
199
200
func TestActionsArtifactDownloadMultiFiles (t * testing.T ) {
200
201
defer tests .PrepareTestEnv (t )()
201
202
202
- const testArtifactName = "multi-files "
203
+ const testArtifactName = "multi-file-download "
203
204
204
205
req := NewRequest (t , "GET" , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" ).
205
206
AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
@@ -226,7 +227,7 @@ func TestActionsArtifactDownloadMultiFiles(t *testing.T) {
226
227
DecodeJSON (t , resp , & downloadResp )
227
228
assert .Len (t , downloadResp .Value , 2 )
228
229
229
- downloads := [][]string {{"multi-files /abc.txt" , "A " }, {"multi-files /xyz/def.txt" , "B " }}
230
+ downloads := [][]string {{"multi-file-download /abc.txt" , "B " }, {"multi-file-download /xyz/def.txt" , "C " }}
230
231
for _ , v := range downloadResp .Value {
231
232
var bodyChar string
232
233
var path string
@@ -247,8 +248,7 @@ func TestActionsArtifactDownloadMultiFiles(t *testing.T) {
247
248
req = NewRequest (t , "GET" , url ).
248
249
AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
249
250
resp = MakeRequest (t , req , http .StatusOK )
250
- body := strings .Repeat (bodyChar , 1024 )
251
- assert .Equal (t , resp .Body .String (), body )
251
+ assert .Equal (t , strings .Repeat (bodyChar , 1024 ), resp .Body .String ())
252
252
}
253
253
}
254
254
0 commit comments