mirror of
1
Fork 0
forgejo/tests/integration/api_repo_actions_test.go

44 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"
"code.gitea.io/gitea/routers/api/v1/shared"
"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 shared.RunJobList
DecodeJSON(t, res, &jobs)
assert.Len(t, jobs.Body, 1)
assert.EqualValues(t, job.ID, jobs.Body[0].ID)
}