2025-01-14 12:17:42 +01:00
|
|
|
// Copyright 2025 The Forgejo Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
actions_model "code.gitea.io/gitea/models/actions"
|
|
|
|
auth_model "code.gitea.io/gitea/models/auth"
|
|
|
|
"code.gitea.io/gitea/models/unittest"
|
2025-02-24 19:14:12 +01:00
|
|
|
api "code.gitea.io/gitea/modules/structs"
|
2025-01-14 12:17:42 +01:00
|
|
|
"code.gitea.io/gitea/tests"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAPISearchActionJobs_OrgRunner(t *testing.T) {
|
|
|
|
defer tests.PrepareTestEnv(t)()
|
|
|
|
|
|
|
|
session := loginUser(t, "user1")
|
|
|
|
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteOrganization)
|
|
|
|
|
|
|
|
job := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRunJob{ID: 395})
|
|
|
|
|
|
|
|
req := NewRequest(t, "GET",
|
|
|
|
fmt.Sprintf("/api/v1/orgs/org3/actions/runners/jobs?labels=%s", "fedora")).
|
|
|
|
AddTokenAuth(token)
|
|
|
|
res := MakeRequest(t, req, http.StatusOK)
|
|
|
|
|
2025-02-24 19:14:12 +01:00
|
|
|
var jobs []*api.ActionRunJob
|
2025-01-14 12:17:42 +01:00
|
|
|
DecodeJSON(t, res, &jobs)
|
|
|
|
|
2025-02-24 19:14:12 +01:00
|
|
|
assert.Len(t, jobs, 1)
|
|
|
|
assert.EqualValues(t, job.ID, jobs[0].ID)
|
2025-01-14 12:17:42 +01:00
|
|
|
}
|