mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-03-04 08:14:43 +01:00
fix: job list response to avoid wrapped body. (#7050)
Some checks are pending
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
Some checks are pending
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
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>
This commit is contained in:
parent
768f5a9255
commit
a4778fc970
6 changed files with 24 additions and 25 deletions
|
@ -34,13 +34,6 @@ func GetRegistrationToken(ctx *context.APIContext, ownerID, repoID int64) {
|
|||
ctx.JSON(http.StatusOK, RegistrationToken{Token: token.Token})
|
||||
}
|
||||
|
||||
// RunJobList is a list of action run jobs
|
||||
// swagger:response RunJobList
|
||||
type RunJobList struct {
|
||||
// in:body
|
||||
Body []*structs.ActionRunJob `json:"body"`
|
||||
}
|
||||
|
||||
func GetActionRunJobs(ctx *context.APIContext, ownerID, repoID int64) {
|
||||
labels := strings.Split(ctx.FormTrim("labels"), ",")
|
||||
|
||||
|
@ -54,8 +47,7 @@ func GetActionRunJobs(ctx *context.APIContext, ownerID, repoID int64) {
|
|||
return
|
||||
}
|
||||
|
||||
res := new(RunJobList)
|
||||
res.Body = fromRunJobModelToResponse(total, labels)
|
||||
res := fromRunJobModelToResponse(total, labels)
|
||||
|
||||
ctx.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
|
|
@ -32,3 +32,10 @@ type swaggerResponseVariableList struct {
|
|||
// in:body
|
||||
Body []api.ActionVariable `json:"body"`
|
||||
}
|
||||
|
||||
// RunJobList is a list of action run jobs
|
||||
// swagger:response RunJobList
|
||||
type swaggerRunJobList struct {
|
||||
// in:body
|
||||
Body []*api.ActionRunJob `json:"body"`
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
actions_model "code.gitea.io/gitea/models/actions"
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/routers/api/v1/shared"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -31,9 +31,9 @@ func TestAPISearchActionJobs_GlobalRunner(t *testing.T) {
|
|||
).AddTokenAuth(token)
|
||||
res := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var jobs shared.RunJobList
|
||||
var jobs []*api.ActionRunJob
|
||||
DecodeJSON(t, res, &jobs)
|
||||
|
||||
assert.Len(t, jobs.Body, 1)
|
||||
assert.EqualValues(t, job.ID, jobs.Body[0].ID)
|
||||
assert.Len(t, jobs, 1)
|
||||
assert.EqualValues(t, job.ID, jobs[0].ID)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
actions_model "code.gitea.io/gitea/models/actions"
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/routers/api/v1/shared"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -30,9 +30,9 @@ func TestAPISearchActionJobs_OrgRunner(t *testing.T) {
|
|||
AddTokenAuth(token)
|
||||
res := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var jobs shared.RunJobList
|
||||
var jobs []*api.ActionRunJob
|
||||
DecodeJSON(t, res, &jobs)
|
||||
|
||||
assert.Len(t, jobs.Body, 1)
|
||||
assert.EqualValues(t, job.ID, jobs.Body[0].ID)
|
||||
assert.Len(t, jobs, 1)
|
||||
assert.EqualValues(t, job.ID, jobs[0].ID)
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/routers/api/v1/shared"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -35,9 +35,9 @@ func TestAPISearchActionJobs_RepoRunner(t *testing.T) {
|
|||
).AddTokenAuth(token)
|
||||
res := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var jobs shared.RunJobList
|
||||
var jobs []*api.ActionRunJob
|
||||
DecodeJSON(t, res, &jobs)
|
||||
|
||||
assert.Len(t, jobs.Body, 1)
|
||||
assert.EqualValues(t, job.ID, jobs.Body[0].ID)
|
||||
assert.Len(t, jobs, 1)
|
||||
assert.EqualValues(t, job.ID, jobs[0].ID)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
actions_model "code.gitea.io/gitea/models/actions"
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/routers/api/v1/shared"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -30,9 +30,9 @@ func TestAPISearchActionJobs_UserRunner(t *testing.T) {
|
|||
AddTokenAuth(token)
|
||||
res := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var jobs shared.RunJobList
|
||||
var jobs []*api.ActionRunJob
|
||||
DecodeJSON(t, res, &jobs)
|
||||
|
||||
assert.Len(t, jobs.Body, 1)
|
||||
assert.EqualValues(t, job.ID, jobs.Body[0].ID)
|
||||
assert.Len(t, jobs, 1)
|
||||
assert.EqualValues(t, job.ID, jobs[0].ID)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue