Skip to content

Commit 0f70445

Browse files
committed
bug: fix context and gomega usage in tests
Signed-off-by: Kevin Conner <[email protected]>
1 parent d122430 commit 0f70445

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

internal/controller/pod_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ var _ = Describe("PodReconciler", func() {
116116
Expect(removeEvents).To(HaveLen(1))
117117
Expect(removeEvents[0]).To(Equal(pod.UID))
118118

119-
Eventually(func() []string {
119+
Eventually(ctx, func(ctx context.Context) []string {
120120
updatedPod := &corev1.Pod{}
121121
err := fakeClient.Get(ctx, req.NamespacedName, updatedPod)
122122
if err != nil {

internal/tracker/status_tracker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func expectPodCount(
4343
mvKey types.NamespacedName,
4444
injected, uninjected, orphaned int32,
4545
) {
46-
Eventually(func() bool {
46+
Eventually(ctx, func(ctx context.Context) bool {
4747
updatedMV := testutil.GetModelValidationFromClientExpected(ctx, fakeClient, mvKey)
4848
return updatedMV.Status.InjectedPodCount == injected &&
4949
updatedMV.Status.UninjectedPodCount == uninjected &&

internal/webhooks/pod_webhook_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ var _ = Describe("Pod webhook", func() {
8080

8181
By("Checking that validation sidecar was created")
8282
found := &corev1.Pod{}
83-
Eventually(func() error {
83+
Eventually(ctx, func(ctx context.Context) error {
8484
return k8sClient.Get(ctx, typeNamespaceName, found)
85-
}).Should(Succeed())
85+
}, 5*time.Second).Should(Succeed())
8686

87-
Eventually(
88-
func(_ Gomega) []corev1.Container {
89-
Expect(k8sClient.Get(ctx, typeNamespaceName, found)).To(Succeed())
87+
Eventually(ctx,
88+
func(g Gomega, ctx context.Context) []corev1.Container {
89+
g.Expect(k8sClient.Get(ctx, typeNamespaceName, found)).To(Succeed())
9090
return found.Spec.InitContainers
91-
},
91+
}, 5*time.Second,
9292
).Should(And(
9393
WithTransform(func(containers []corev1.Container) int { return len(containers) }, Equal(1)),
9494
WithTransform(
@@ -112,17 +112,17 @@ var _ = Describe("Pod webhook", func() {
112112

113113
By("Waiting for pod to be injected")
114114
found := &corev1.Pod{}
115-
Eventually(func() []corev1.Container {
115+
Eventually(ctx, func(ctx context.Context) []corev1.Container {
116116
_ = k8sClient.Get(ctx, types.NamespacedName{Name: "tracked-pod", Namespace: Namespace}, found)
117117
return found.Spec.InitContainers
118-
}).Should(HaveLen(1))
118+
}, 5*time.Second).Should(HaveLen(1))
119119

120120
err = statusTracker.ProcessPodEvent(ctx, found)
121121
Expect(err).To(Not(HaveOccurred()))
122122

123123
By("Checking ModelValidation status was updated")
124124
mv := &v1alpha1.ModelValidation{}
125-
Eventually(func() int32 {
125+
Eventually(ctx, func(ctx context.Context) int32 {
126126
_ = k8sClient.Get(ctx, typeNamespaceName, mv)
127127
return mv.Status.InjectedPodCount
128128
}, 5*time.Second).Should(BeNumerically(">", 0))

0 commit comments

Comments
 (0)