@@ -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,19 +115,19 @@ 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 )
118+ assert .Equal (t , int64 (2 ), listResp .Count )
119+ assert .Equal (t , "artifact-download " , listResp .Value [0 ].Name )
120120 assert .Contains (t , listResp .Value [0 ].FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" )
121121
122122 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 "
124124 req = NewRequest (t , "GET" , url ).
125125 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
126126 resp = MakeRequest (t , req , http .StatusOK )
127127 var downloadResp downloadArtifactResponse
128128 DecodeJSON (t , resp , & downloadResp )
129129 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 )
131131 assert .Equal (t , "file" , downloadResp .Value [0 ].ItemType )
132132 assert .Contains (t , downloadResp .Value [0 ].ContentLocation , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" )
133133
@@ -136,8 +136,9 @@ func TestActionsArtifactDownload(t *testing.T) {
136136 req = NewRequest (t , "GET" , url ).
137137 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
138138 resp = MakeRequest (t , req , http .StatusOK )
139+
139140 body := strings .Repeat ("A" , 1024 )
140- assert .Equal (t , resp .Body .String (), body )
141+ assert .Equal (t , body , resp .Body .String ())
141142}
142143
143144func TestActionsArtifactUploadMultipleFile (t * testing.T ) {
@@ -163,14 +164,14 @@ func TestActionsArtifactUploadMultipleFile(t *testing.T) {
163164
164165 files := []uploadingFile {
165166 {
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 ==" ,
169170 },
170171 {
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 ==" ,
174175 },
175176 }
176177
@@ -199,7 +200,7 @@ func TestActionsArtifactUploadMultipleFile(t *testing.T) {
199200func TestActionsArtifactDownloadMultiFiles (t * testing.T ) {
200201 defer tests .PrepareTestEnv (t )()
201202
202- const testArtifactName = "multi-files "
203+ const testArtifactName = "multi-file-download "
203204
204205 req := NewRequest (t , "GET" , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" ).
205206 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
@@ -226,7 +227,7 @@ func TestActionsArtifactDownloadMultiFiles(t *testing.T) {
226227 DecodeJSON (t , resp , & downloadResp )
227228 assert .Len (t , downloadResp .Value , 2 )
228229
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 " }}
230231 for _ , v := range downloadResp .Value {
231232 var bodyChar string
232233 var path string
@@ -247,8 +248,7 @@ func TestActionsArtifactDownloadMultiFiles(t *testing.T) {
247248 req = NewRequest (t , "GET" , url ).
248249 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
249250 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 ())
252252 }
253253}
254254
0 commit comments