Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug in actions artifact test #32672

Merged
merged 2 commits into from
Nov 29, 2024
Merged

Conversation

Zettat123
Copy link
Contributor

This bug exists in TestActionsArtifactDownload.

var listResp listArtifactsResponse
DecodeJSON(t, resp, &listResp)
assert.Equal(t, int64(2), listResp.Count)
// Return list might be in any order. Get one file.
var artifactIdx int
for i, artifact := range listResp.Value {
if artifact.Name == "artifact-download" {
artifactIdx = i
break
}
}

We assert that listResp.Count is 2, so artifactIdx could be 0 or 1.

var downloadResp downloadArtifactResponse
DecodeJSON(t, resp, &downloadResp)
assert.Len(t, downloadResp.Value, 1)
assert.Equal(t, "artifact-download/abc.txt", downloadResp.Value[artifactIdx].Path)

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.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Nov 29, 2024
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 29, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Nov 29, 2024
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Nov 29, 2024
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Nov 29, 2024
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Nov 29, 2024
@lunny lunny enabled auto-merge (squash) November 29, 2024 20:07
@lunny lunny merged commit fd3aa5b into go-gitea:main Nov 29, 2024
26 checks passed
@GiteaBot GiteaBot added this to the 1.24.0 milestone Nov 29, 2024
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Nov 29, 2024
@lunny lunny modified the milestones: 1.24.0, 1.23.0 Nov 29, 2024
zjjhot added a commit to zjjhot/gitea that referenced this pull request Nov 30, 2024
* giteaofficial/main:
  Split mail sender sub package from mailer service package (go-gitea#32618)
  Fix a bug in actions artifact test (go-gitea#32672)
  Move GetFeeds to service layer (go-gitea#32526)
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Feb 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants