Skip to content

Commit b300a49

Browse files
committed
fix test regression after run deletion
1 parent 42ca070 commit b300a49

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

models/fixtures/action_run.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
ref: "refs/heads/test"
131131
commit_sha: "c2d72f548424103f01ee1dc02889c1e2bff816b0"
132132
event: "push"
133+
trigger_event: "push"
133134
is_fork_pull_request: 0
134135
status: 2
135136
started: 1683636528

tests/integration/workflow_run_api_check_test.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ import (
1717
)
1818

1919
func TestAPIWorkflowRun(t *testing.T) {
20-
t.Run("AdminRunner", func(t *testing.T) {
21-
testAPIWorkflowRunBasic(t, "/api/v1/admin/actions", 6, "User1", 802, auth_model.AccessTokenScopeReadAdmin, auth_model.AccessTokenScopeReadRepository)
20+
t.Run("AdminRuns", func(t *testing.T) {
21+
testAPIWorkflowRunBasic(t, "/api/v1/admin/actions", "User1", 802, auth_model.AccessTokenScopeReadAdmin, auth_model.AccessTokenScopeReadRepository)
2222
})
23-
t.Run("UserRunner", func(t *testing.T) {
24-
testAPIWorkflowRunBasic(t, "/api/v1/user/actions", 1, "User2", 803, auth_model.AccessTokenScopeReadUser, auth_model.AccessTokenScopeReadRepository)
23+
t.Run("UserRuns", func(t *testing.T) {
24+
testAPIWorkflowRunBasic(t, "/api/v1/user/actions", "User2", 803, auth_model.AccessTokenScopeReadUser, auth_model.AccessTokenScopeReadRepository)
2525
})
2626
t.Run("OrgRuns", func(t *testing.T) {
27-
testAPIWorkflowRunBasic(t, "/api/v1/orgs/org3/actions", 1, "User1", 802, auth_model.AccessTokenScopeReadOrganization, auth_model.AccessTokenScopeReadRepository)
27+
testAPIWorkflowRunBasic(t, "/api/v1/orgs/org3/actions", "User1", 802, auth_model.AccessTokenScopeReadOrganization, auth_model.AccessTokenScopeReadRepository)
2828
})
2929
t.Run("RepoRuns", func(t *testing.T) {
30-
testAPIWorkflowRunBasic(t, "/api/v1/repos/org3/repo5/actions", 1, "User2", 802, auth_model.AccessTokenScopeReadRepository)
30+
testAPIWorkflowRunBasic(t, "/api/v1/repos/org3/repo5/actions", "User2", 802, auth_model.AccessTokenScopeReadRepository)
3131
})
3232
}
3333

34-
func testAPIWorkflowRunBasic(t *testing.T, apiRootURL string, itemCount int, userUsername string, runID int64, scope ...auth_model.AccessTokenScope) {
34+
func testAPIWorkflowRunBasic(t *testing.T, apiRootURL string, userUsername string, runID int64, scope ...auth_model.AccessTokenScope) {
3535
defer tests.PrepareTestEnv(t)()
3636
token := getUserToken(t, userUsername, scope...)
3737

@@ -41,19 +41,29 @@ func testAPIWorkflowRunBasic(t *testing.T, apiRootURL string, itemCount int, use
4141
runnerList := api.ActionWorkflowRunsResponse{}
4242
DecodeJSON(t, runnerListResp, &runnerList)
4343

44-
assert.Len(t, runnerList.Entries, itemCount)
45-
4644
foundRun := false
4745

4846
for _, run := range runnerList.Entries {
47+
// Verify filtering works
4948
verifyWorkflowRunCanbeFoundWithStatusFilter(t, apiRunsURL, token, run.ID, "", run.Status, "", "", "", "")
5049
verifyWorkflowRunCanbeFoundWithStatusFilter(t, apiRunsURL, token, run.ID, run.Conclusion, "", "", "", "", "")
5150
verifyWorkflowRunCanbeFoundWithStatusFilter(t, apiRunsURL, token, run.ID, "", "", "", run.HeadBranch, "", "")
5251
verifyWorkflowRunCanbeFoundWithStatusFilter(t, apiRunsURL, token, run.ID, "", "", run.Event, "", "", "")
5352
verifyWorkflowRunCanbeFoundWithStatusFilter(t, apiRunsURL, token, run.ID, "", "", "", "", run.TriggerActor.UserName, "")
5453
verifyWorkflowRunCanbeFoundWithStatusFilter(t, apiRunsURL, token, run.ID, "", "", "", "", run.TriggerActor.UserName, run.HeadSha)
5554

56-
req := NewRequest(t, "GET", fmt.Sprintf("%s/%s", run.URL, "jobs")).AddTokenAuth(token)
55+
// Verify run url works
56+
req := NewRequest(t, "GET", run.URL).AddTokenAuth(token)
57+
runResp := MakeRequest(t, req, http.StatusOK)
58+
apiRun := api.ActionWorkflowRun{}
59+
DecodeJSON(t, runResp, &apiRun)
60+
assert.Equal(t, run.ID, apiRun.ID)
61+
assert.Equal(t, run.Status, apiRun.Status)
62+
assert.Equal(t, run.Conclusion, apiRun.Conclusion)
63+
assert.Equal(t, run.Event, apiRun.Event)
64+
65+
// Verify jobs list works
66+
req = NewRequest(t, "GET", fmt.Sprintf("%s/%s", run.URL, "jobs")).AddTokenAuth(token)
5767
jobsResp := MakeRequest(t, req, http.StatusOK)
5868
jobList := api.ActionWorkflowJobsResponse{}
5969
DecodeJSON(t, jobsResp, &jobList)
@@ -69,6 +79,7 @@ func testAPIWorkflowRunBasic(t *testing.T, apiRootURL string, itemCount int, use
6979
verifyWorkflowJobCanbeFoundWithStatusFilter(t, fmt.Sprintf("%s/%s", apiRootURL, "jobs"), token, job.ID, "", job.Status)
7080
verifyWorkflowJobCanbeFoundWithStatusFilter(t, fmt.Sprintf("%s/%s", apiRootURL, "jobs"), token, job.ID, job.Conclusion, "")
7181

82+
// Verify job url works
7283
req := NewRequest(t, "GET", job.URL).AddTokenAuth(token)
7384
jobsResp := MakeRequest(t, req, http.StatusOK)
7485
apiJob := api.ActionWorkflowJob{}

0 commit comments

Comments
 (0)