From 1e7976628c7be8d9922b0324668009a541f51d24 Mon Sep 17 00:00:00 2001 From: Soule BA Date: Mon, 22 Jan 2024 22:42:57 +0100 Subject: [PATCH] attempt to fix flaky test Signed-off-by: Soule BA --- gitea/integration_repositories_user_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gitea/integration_repositories_user_test.go b/gitea/integration_repositories_user_test.go index 3c9d342..3892701 100644 --- a/gitea/integration_repositories_user_test.go +++ b/gitea/integration_repositories_user_test.go @@ -299,7 +299,17 @@ var _ = Describe("Gitea Provider", func() { Expect(pr.Get().WebURL).ToNot(BeEmpty()) Expect(pr.Get().Merged).To(BeFalse()) - err = userRepo.PullRequests().Merge(ctx, pr.Get().Number, gitprovider.MergeMethodMerge, "merged") + Eventually(func() bool { + var err error + getPR, err = userRepo.PullRequests().Get(ctx, pr.Get().Number) + pr := getPR.APIObject().(*gitea.PullRequest) + if err != nil || !pr.Mergeable { + err = errors.New("pull request not ready to merge") + } + return retryOp.IsRetryable(err, fmt.Sprintf("get pull request, repository: %s", userRepo.Repository().GetRepository())) + }, retryOp.Timeout(), retryOp.Interval()).Should(BeTrue()) + + err = userRepo.PullRequests().Merge(ctx, getPR.Get().Number, gitprovider.MergeMethodMerge, "merged") Expect(err).ToNot(HaveOccurred()) getPR, err = userRepo.PullRequests().Get(ctx, pr.Get().Number)