From 305e05957333c44292a05a7cd8e62eec077a5b9e Mon Sep 17 00:00:00 2001 From: forgejo-backport-action Date: Wed, 10 Sep 2025 19:08:02 +0200 Subject: [PATCH] [v11.0/forgejo] chore: fix transient error in TestPatchStatus tests (#9238) **Backport:** https://codeberg.org/forgejo/forgejo/pulls/9236 wait on all pull requests before checking their conflict status because there is no guarantee one will be dealt with before another Refs https://codeberg.org/forgejo/forgejo/issues/8221#issuecomment-6849601 Co-authored-by: Earl Warren Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9238 Reviewed-by: Earl Warren Co-authored-by: forgejo-backport-action Co-committed-by: forgejo-backport-action --- tests/integration/patch_status_test.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/integration/patch_status_test.go b/tests/integration/patch_status_test.go index db417514d8..f5a07b148a 100644 --- a/tests/integration/patch_status_test.go +++ b/tests/integration/patch_status_test.go @@ -140,11 +140,16 @@ func TestPatchStatus(t *testing.T) { require.NoError(t, git.NewCommand(t.Context(), "push", "origin", "HEAD:main").Run(&git.RunOpts{Dir: dstPath})) require.NoError(t, git.NewCommand(t.Context(), "switch", "normal").Run(&git.RunOpts{Dir: dstPath})) + assertConflictAndLoadBean := func(t *testing.T, pr *issues_model.PullRequest, flow string) *issues_model.PullRequest { + t.Helper() + assert.Eventually(t, func() bool { + return unittest.AssertExistsAndLoadBean(t, pr, flow).Status == issues_model.PullRequestStatusConflict + }, time.Second*30, time.Millisecond*200) + return pr + } // Wait until status check queue is done, we cannot access the queue's // internal information so we rely on the status of the patch being changed. - assert.Eventually(t, func() bool { - return unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: normalAGitPR.ID}).Status == issues_model.PullRequestStatusConflict - }, time.Second*30, time.Millisecond*200) + _ = assertConflictAndLoadBean(t, &issues_model.PullRequest{ID: normalAGitPR.ID}, "flow = 1") test := func(t *testing.T, pr *issues_model.PullRequest) { t.Helper() @@ -161,7 +166,7 @@ func TestPatchStatus(t *testing.T) { t.Run("Existing", func(t *testing.T) { defer tests.PrintCurrentTest(t)() - pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{BaseRepoID: repo.ID, HeadRepoID: forkRepo.ID, HeadBranch: "normal"}, "flow = 0") + pr := assertConflictAndLoadBean(t, &issues_model.PullRequest{BaseRepoID: repo.ID, HeadRepoID: forkRepo.ID, HeadBranch: "normal"}, "flow = 0") test(t, pr) testAutomergeQueued(t, pr, issues_model.PullRequestStatusConflict) }) @@ -172,7 +177,7 @@ func TestPatchStatus(t *testing.T) { require.NoError(t, git.NewCommand(t.Context(), "push", "fork", "HEAD:conflict").Run(&git.RunOpts{Dir: dstPath})) testPullCreateDirectly(t, session, repo.OwnerName, repo.Name, repo.DefaultBranch, forkRepo.OwnerName, forkRepo.Name, "conflict", "across repo conflict") - test(t, unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{BaseRepoID: repo.ID, HeadRepoID: forkRepo.ID, HeadBranch: "conflict"}, "flow = 0")) + test(t, assertConflictAndLoadBean(t, &issues_model.PullRequest{BaseRepoID: repo.ID, HeadRepoID: forkRepo.ID, HeadBranch: "conflict"}, "flow = 0")) }) })