diff options
author | Zettat123 <zettat123@gmail.com> | 2024-11-30 04:32:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-29 20:32:10 +0000 |
commit | fd3aa5bedb07d295d48b1f550c19ad1b387ba83f (patch) | |
tree | 8aee956387695eb54b61474295c1dc3e87026ede /tests | |
parent | 1ed5f379b9f3e38b64cc9de9f418c164ce400be1 (diff) | |
download | gitea-fd3aa5bedb07d295d48b1f550c19ad1b387ba83f.tar.gz gitea-fd3aa5bedb07d295d48b1f550c19ad1b387ba83f.zip |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/api_actions_artifact_test.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/integration/api_actions_artifact_test.go b/tests/integration/api_actions_artifact_test.go index de5797f289..29e9930538 100644 --- a/tests/integration/api_actions_artifact_test.go +++ b/tests/integration/api_actions_artifact_test.go @@ -144,12 +144,12 @@ func TestActionsArtifactDownload(t *testing.T) { var downloadResp downloadArtifactResponse DecodeJSON(t, resp, &downloadResp) assert.Len(t, downloadResp.Value, 1) - assert.Equal(t, "artifact-download/abc.txt", downloadResp.Value[artifactIdx].Path) - assert.Equal(t, "file", downloadResp.Value[artifactIdx].ItemType) - assert.Contains(t, downloadResp.Value[artifactIdx].ContentLocation, "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts") + assert.Equal(t, "artifact-download/abc.txt", downloadResp.Value[0].Path) + assert.Equal(t, "file", downloadResp.Value[0].ItemType) + assert.Contains(t, downloadResp.Value[0].ContentLocation, "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts") - idx = strings.Index(downloadResp.Value[artifactIdx].ContentLocation, "/api/actions_pipeline/_apis/pipelines/") - url = downloadResp.Value[artifactIdx].ContentLocation[idx:] + idx = strings.Index(downloadResp.Value[0].ContentLocation, "/api/actions_pipeline/_apis/pipelines/") + url = downloadResp.Value[0].ContentLocation[idx:] req = NewRequest(t, "GET", url). AddTokenAuth("8061e833a55f6fc0157c98b883e91fcfeeb1a71a") resp = MakeRequest(t, req, http.StatusOK) |