From f8c472ba0afb1c53bbd5655d76f873aa29ab5db0 Mon Sep 17 00:00:00 2001 From: lpugoy <44182754+lpugoy@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:32:10 +1100 Subject: [PATCH] Simplify if condition in cronjob tutorial --- .../project/internal/controller/cronjob_controller_test.go | 5 +---- .../internal/cronjob-tutorial/writing_tests_controller.go | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller_test.go b/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller_test.go index d28c25d53aa..9b95c3d362d 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller_test.go +++ b/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller_test.go @@ -115,10 +115,7 @@ var _ = Describe("CronJob controller", func() { // We'll need to retry getting this newly created CronJob, given that creation may not immediately happen. Eventually(func() bool { err := k8sClient.Get(ctx, cronjobLookupKey, createdCronjob) - if err != nil { - return false - } - return true + return err == nil }, timeout, interval).Should(BeTrue()) // Let's make sure our Schedule string value was properly converted/handled. Expect(createdCronjob.Spec.Schedule).Should(Equal("1 * * * *")) diff --git a/hack/docs/internal/cronjob-tutorial/writing_tests_controller.go b/hack/docs/internal/cronjob-tutorial/writing_tests_controller.go index 5add3f32ffc..01b8998d6ba 100644 --- a/hack/docs/internal/cronjob-tutorial/writing_tests_controller.go +++ b/hack/docs/internal/cronjob-tutorial/writing_tests_controller.go @@ -134,10 +134,7 @@ var _ = Describe("CronJob controller", func() { // We'll need to retry getting this newly created CronJob, given that creation may not immediately happen. Eventually(func() bool { err := k8sClient.Get(ctx, cronjobLookupKey, createdCronjob) - if err != nil { - return false - } - return true + return err == nil }, timeout, interval).Should(BeTrue()) // Let's make sure our Schedule string value was properly converted/handled. Expect(createdCronjob.Spec.Schedule).Should(Equal("1 * * * *"))