Skip to content

Commit fd3aa5b

Browse files
authored
Fix a bug in actions artifact test (#32672)
This bug exists in `TestActionsArtifactDownload`. https://github.com/go-gitea/gitea/blob/a1f56f83bff56f86180e59742efd3748908b82c1/tests/integration/api_actions_artifact_test.go#L123-L134 We assert that `listResp.Count` is `2`, so `artifactIdx` could be `0` or `1`. https://github.com/go-gitea/gitea/blob/a1f56f83bff56f86180e59742efd3748908b82c1/tests/integration/api_actions_artifact_test.go#L144-L147 Then we assert that the length of `downloadResp.Value` is `1`. If `artifactIdx` is `1` at this point, the assertion on Line 147 will throw an `index out of range` error.
1 parent 1ed5f37 commit fd3aa5b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/integration/api_actions_artifact_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ func TestActionsArtifactDownload(t *testing.T) {
144144
var downloadResp downloadArtifactResponse
145145
DecodeJSON(t, resp, &downloadResp)
146146
assert.Len(t, downloadResp.Value, 1)
147-
assert.Equal(t, "artifact-download/abc.txt", downloadResp.Value[artifactIdx].Path)
148-
assert.Equal(t, "file", downloadResp.Value[artifactIdx].ItemType)
149-
assert.Contains(t, downloadResp.Value[artifactIdx].ContentLocation, "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts")
147+
assert.Equal(t, "artifact-download/abc.txt", downloadResp.Value[0].Path)
148+
assert.Equal(t, "file", downloadResp.Value[0].ItemType)
149+
assert.Contains(t, downloadResp.Value[0].ContentLocation, "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts")
150150

151-
idx = strings.Index(downloadResp.Value[artifactIdx].ContentLocation, "/api/actions_pipeline/_apis/pipelines/")
152-
url = downloadResp.Value[artifactIdx].ContentLocation[idx:]
151+
idx = strings.Index(downloadResp.Value[0].ContentLocation, "/api/actions_pipeline/_apis/pipelines/")
152+
url = downloadResp.Value[0].ContentLocation[idx:]
153153
req = NewRequest(t, "GET", url).
154154
AddTokenAuth("8061e833a55f6fc0157c98b883e91fcfeeb1a71a")
155155
resp = MakeRequest(t, req, http.StatusOK)

0 commit comments

Comments
 (0)