loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: job list response to avoid wrapped body. (#7050)

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7050
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Jaime merino <cobak78@gmail.com>
Co-committed-by: Jaime merino <cobak78@gmail.com>

authored by

Jaime merino
Jaime merino
and committed by
Gusted
a4778fc9 768f5a92

+24 -25
+1 -9
routers/api/v1/shared/runners.go
··· 34 34 ctx.JSON(http.StatusOK, RegistrationToken{Token: token.Token}) 35 35 } 36 36 37 - // RunJobList is a list of action run jobs 38 - // swagger:response RunJobList 39 - type RunJobList struct { 40 - // in:body 41 - Body []*structs.ActionRunJob `json:"body"` 42 - } 43 - 44 37 func GetActionRunJobs(ctx *context.APIContext, ownerID, repoID int64) { 45 38 labels := strings.Split(ctx.FormTrim("labels"), ",") 46 39 ··· 54 47 return 55 48 } 56 49 57 - res := new(RunJobList) 58 - res.Body = fromRunJobModelToResponse(total, labels) 50 + res := fromRunJobModelToResponse(total, labels) 59 51 60 52 ctx.JSON(http.StatusOK, res) 61 53 }
+7
routers/api/v1/swagger/action.go
··· 32 32 // in:body 33 33 Body []api.ActionVariable `json:"body"` 34 34 } 35 + 36 + // RunJobList is a list of action run jobs 37 + // swagger:response RunJobList 38 + type swaggerRunJobList struct { 39 + // in:body 40 + Body []*api.ActionRunJob `json:"body"` 41 + }
+4 -4
tests/integration/api_admin_actions_test.go
··· 11 11 actions_model "code.gitea.io/gitea/models/actions" 12 12 auth_model "code.gitea.io/gitea/models/auth" 13 13 "code.gitea.io/gitea/models/unittest" 14 - "code.gitea.io/gitea/routers/api/v1/shared" 14 + api "code.gitea.io/gitea/modules/structs" 15 15 "code.gitea.io/gitea/tests" 16 16 17 17 "github.com/stretchr/testify/assert" ··· 31 31 ).AddTokenAuth(token) 32 32 res := MakeRequest(t, req, http.StatusOK) 33 33 34 - var jobs shared.RunJobList 34 + var jobs []*api.ActionRunJob 35 35 DecodeJSON(t, res, &jobs) 36 36 37 - assert.Len(t, jobs.Body, 1) 38 - assert.EqualValues(t, job.ID, jobs.Body[0].ID) 37 + assert.Len(t, jobs, 1) 38 + assert.EqualValues(t, job.ID, jobs[0].ID) 39 39 }
+4 -4
tests/integration/api_org_actions_test.go
··· 11 11 actions_model "code.gitea.io/gitea/models/actions" 12 12 auth_model "code.gitea.io/gitea/models/auth" 13 13 "code.gitea.io/gitea/models/unittest" 14 - "code.gitea.io/gitea/routers/api/v1/shared" 14 + api "code.gitea.io/gitea/modules/structs" 15 15 "code.gitea.io/gitea/tests" 16 16 17 17 "github.com/stretchr/testify/assert" ··· 30 30 AddTokenAuth(token) 31 31 res := MakeRequest(t, req, http.StatusOK) 32 32 33 - var jobs shared.RunJobList 33 + var jobs []*api.ActionRunJob 34 34 DecodeJSON(t, res, &jobs) 35 35 36 - assert.Len(t, jobs.Body, 1) 37 - assert.EqualValues(t, job.ID, jobs.Body[0].ID) 36 + assert.Len(t, jobs, 1) 37 + assert.EqualValues(t, job.ID, jobs[0].ID) 38 38 }
+4 -4
tests/integration/api_repo_actions_test.go
··· 12 12 repo_model "code.gitea.io/gitea/models/repo" 13 13 "code.gitea.io/gitea/models/unittest" 14 14 user_model "code.gitea.io/gitea/models/user" 15 - "code.gitea.io/gitea/routers/api/v1/shared" 15 + api "code.gitea.io/gitea/modules/structs" 16 16 "code.gitea.io/gitea/tests" 17 17 18 18 "github.com/stretchr/testify/assert" ··· 35 35 ).AddTokenAuth(token) 36 36 res := MakeRequest(t, req, http.StatusOK) 37 37 38 - var jobs shared.RunJobList 38 + var jobs []*api.ActionRunJob 39 39 DecodeJSON(t, res, &jobs) 40 40 41 - assert.Len(t, jobs.Body, 1) 42 - assert.EqualValues(t, job.ID, jobs.Body[0].ID) 41 + assert.Len(t, jobs, 1) 42 + assert.EqualValues(t, job.ID, jobs[0].ID) 43 43 }
+4 -4
tests/integration/api_user_actions_test.go
··· 11 11 actions_model "code.gitea.io/gitea/models/actions" 12 12 auth_model "code.gitea.io/gitea/models/auth" 13 13 "code.gitea.io/gitea/models/unittest" 14 - "code.gitea.io/gitea/routers/api/v1/shared" 14 + api "code.gitea.io/gitea/modules/structs" 15 15 "code.gitea.io/gitea/tests" 16 16 17 17 "github.com/stretchr/testify/assert" ··· 30 30 AddTokenAuth(token) 31 31 res := MakeRequest(t, req, http.StatusOK) 32 32 33 - var jobs shared.RunJobList 33 + var jobs []*api.ActionRunJob 34 34 DecodeJSON(t, res, &jobs) 35 35 36 - assert.Len(t, jobs.Body, 1) 37 - assert.EqualValues(t, job.ID, jobs.Body[0].ID) 36 + assert.Len(t, jobs, 1) 37 + assert.EqualValues(t, job.ID, jobs[0].ID) 38 38 }