mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-03-12 00:12:37 +01:00
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>
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
// Copyright 2025 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package integration
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
actions_model "code.gitea.io/gitea/models/actions"
|
|
auth_model "code.gitea.io/gitea/models/auth"
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
|
"code.gitea.io/gitea/models/unittest"
|
|
user_model "code.gitea.io/gitea/models/user"
|
|
api "code.gitea.io/gitea/modules/structs"
|
|
"code.gitea.io/gitea/tests"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestAPISearchActionJobs_RepoRunner(t *testing.T) {
|
|
defer tests.PrepareTestEnv(t)()
|
|
|
|
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
|
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
|
token := getUserToken(t, user2.LowerName, auth_model.AccessTokenScopeWriteRepository)
|
|
job := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRunJob{ID: 393})
|
|
|
|
req := NewRequestf(
|
|
t,
|
|
"GET",
|
|
"/api/v1/repos/%s/%s/actions/runners/jobs?labels=%s",
|
|
repo.OwnerName, repo.Name,
|
|
"ubuntu-latest",
|
|
).AddTokenAuth(token)
|
|
res := MakeRequest(t, req, http.StatusOK)
|
|
|
|
var jobs []*api.ActionRunJob
|
|
DecodeJSON(t, res, &jobs)
|
|
|
|
assert.Len(t, jobs, 1)
|
|
assert.EqualValues(t, job.ID, jobs[0].ID)
|
|
}
|