Skip to content

Commit 492368e

Browse files
committed
feat: fix tests
Signed-off-by: Zach Aller <zachaller@users.noreply.github.com>
1 parent 0b88e74 commit 492368e

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

internal/controller/timedcommitstatus_controller_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -343,16 +343,19 @@ var _ = Describe("TimedCommitStatus Controller", Ordered, func() {
343343
// during BeforeEach (TimedCommitStatus resource doesn't exist yet), so PRs would
344344
// auto-merge immediately. We explicitly disable auto-merge to ensure we can observe
345345
// the pending promotion state (proposed != active) before the time gate transitions.
346-
err := k8sClient.Get(ctx, types.NamespacedName{
347-
Name: name,
348-
Namespace: "default",
349-
}, promotionStrategy)
350-
Expect(err).NotTo(HaveOccurred())
346+
Eventually(func(g Gomega) {
347+
var ps promoterv1alpha1.PromotionStrategy
348+
err := k8sClient.Get(ctx, types.NamespacedName{
349+
Name: name,
350+
Namespace: "default",
351+
}, &ps)
352+
g.Expect(err).NotTo(HaveOccurred())
351353

352-
promotionStrategy.Spec.Environments[1].AutoMerge = new(bool) // Set to false (zero value)
353-
*promotionStrategy.Spec.Environments[1].AutoMerge = false
354-
err = k8sClient.Update(ctx, promotionStrategy)
355-
Expect(err).NotTo(HaveOccurred())
354+
ps.Spec.Environments[1].AutoMerge = new(bool) // Set to false (zero value)
355+
*ps.Spec.Environments[1].AutoMerge = false
356+
err = k8sClient.Update(ctx, &ps)
357+
g.Expect(err).NotTo(HaveOccurred(), "Should update PromotionStrategy (retries on conflict)")
358+
}, constants.EventuallyTimeout).Should(Succeed())
356359

357360
By("Creating a pending promotion in staging environment")
358361
gitPath, err := os.MkdirTemp("", "*")

0 commit comments

Comments
 (0)