@@ -116,23 +116,33 @@ func TestActionsArtifactDownload(t *testing.T) {
116116 var listResp listArtifactsResponse
117117 DecodeJSON (t , resp , & listResp )
118118 assert .Equal (t , int64 (2 ), listResp .Count )
119- assert .Equal (t , "artifact-download" , listResp .Value [0 ].Name )
120- assert .Contains (t , listResp .Value [0 ].FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" )
121119
122- idx := strings .Index (listResp .Value [0 ].FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/" )
123- url := listResp .Value [0 ].FileContainerResourceURL [idx + 1 :] + "?itemPath=artifact-download"
120+ // Return list might be in any order. Get one file.
121+ artifact_idx := - 1
122+ for i , artifact := range listResp .Value {
123+ if artifact .Name == "artifact-download" {
124+ artifact_idx = i
125+ break
126+ }
127+ }
128+ assert .True (t , artifact_idx >= 0 )
129+ assert .Equal (t , listResp .Value [artifact_idx ].Name , "artifact-download" )
130+ assert .Contains (t , listResp .Value [artifact_idx ].FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts" )
131+
132+ idx := strings .Index (listResp .Value [artifact_idx ].FileContainerResourceURL , "/api/actions_pipeline/_apis/pipelines/" )
133+ url := listResp .Value [artifact_idx ].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-download/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 [artifact_idx ].Path )
141+ assert .Equal (t , "file" , downloadResp .Value [artifact_idx ].ItemType )
142+ assert .Contains (t , downloadResp .Value [artifact_idx ].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 [artifact_idx ].ContentLocation , "/api/actions_pipeline/_apis/pipelines/" )
145+ url = downloadResp .Value [artifact_idx ].ContentLocation [idx :]
136146 req = NewRequest (t , "GET" , url ).
137147 AddTokenAuth ("8061e833a55f6fc0157c98b883e91fcfeeb1a71a" )
138148 resp = MakeRequest (t , req , http .StatusOK )
0 commit comments