mirror of
https://github.com/bapung/gitea-runner-operator.git
synced 2026-06-22 07:58:44 +00:00
Compare commits
2 Commits
license-to
...
fix/repo-s
| Author | SHA1 | Date | |
|---|---|---|---|
| e6755bf2ba | |||
| 6298940adb |
@@ -131,6 +131,9 @@ func (c *HTTPClient) GetRunnerStats(
|
|||||||
) (*RunnerStats, error) {
|
) (*RunnerStats, error) {
|
||||||
switch scope {
|
switch scope {
|
||||||
case v1alpha1.RunnerGroupScopeRepo:
|
case v1alpha1.RunnerGroupScopeRepo:
|
||||||
|
if user != "" {
|
||||||
|
return c.getRunnerStatsForRepo(ctx, giteaURL, authToken, user, repo, labels)
|
||||||
|
}
|
||||||
return c.getRunnerStatsForRepo(ctx, giteaURL, authToken, org, repo, labels)
|
return c.getRunnerStatsForRepo(ctx, giteaURL, authToken, org, repo, labels)
|
||||||
case v1alpha1.RunnerGroupScopeOrg:
|
case v1alpha1.RunnerGroupScopeOrg:
|
||||||
return c.getRunnerStatsForOrg(ctx, giteaURL, authToken, org, labels)
|
return c.getRunnerStatsForOrg(ctx, giteaURL, authToken, org, labels)
|
||||||
|
|||||||
@@ -80,6 +80,21 @@ func TestHTTPClient_GetRunnerStats(t *testing.T) {
|
|||||||
expectedQueued: 0, // No runner capabilities provided -> no match
|
expectedQueued: 0, // No runner capabilities provided -> no match
|
||||||
expectedError: false,
|
expectedError: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "repo scope (user owned)",
|
||||||
|
scope: v1alpha1.RunnerGroupScopeRepo,
|
||||||
|
user: "testuser",
|
||||||
|
repo: "testrepo",
|
||||||
|
labels: []string{"linux"},
|
||||||
|
mockResponse: ActionWorkflowJobsResponse{
|
||||||
|
TotalCount: 1,
|
||||||
|
Jobs: []ActionWorkflowJob{
|
||||||
|
{ID: 1, Status: "queued", Labels: []string{"linux"}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedQueued: 1,
|
||||||
|
expectedError: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "global scope with specific labels",
|
name: "global scope with specific labels",
|
||||||
scope: v1alpha1.RunnerGroupScopeGlobal,
|
scope: v1alpha1.RunnerGroupScopeGlobal,
|
||||||
@@ -135,9 +150,13 @@ func TestHTTPClient_GetRunnerStats(t *testing.T) {
|
|||||||
expectedPath := ""
|
expectedPath := ""
|
||||||
switch tt.scope {
|
switch tt.scope {
|
||||||
case v1alpha1.RunnerGroupScopeRepo:
|
case v1alpha1.RunnerGroupScopeRepo:
|
||||||
expectedPath = "/api/v1/repos/testorg/testrepo/actions/jobs"
|
owner := tt.org
|
||||||
|
if tt.user != "" {
|
||||||
|
owner = tt.user
|
||||||
|
}
|
||||||
|
expectedPath = "/api/v1/repos/" + owner + "/" + tt.repo + "/actions/jobs"
|
||||||
case v1alpha1.RunnerGroupScopeOrg:
|
case v1alpha1.RunnerGroupScopeOrg:
|
||||||
expectedPath = "/api/v1/orgs/testorg/actions/jobs"
|
expectedPath = "/api/v1/orgs/" + tt.org + "/actions/jobs"
|
||||||
case v1alpha1.RunnerGroupScopeGlobal:
|
case v1alpha1.RunnerGroupScopeGlobal:
|
||||||
expectedPath = "/api/v1/admin/actions/jobs"
|
expectedPath = "/api/v1/admin/actions/jobs"
|
||||||
case v1alpha1.RunnerGroupScopeUser:
|
case v1alpha1.RunnerGroupScopeUser:
|
||||||
|
|||||||
Reference in New Issue
Block a user