Skip to content

Commit a7a3f72

Browse files
authored
📖 Simplify if condition in cronjob tutorial (#3765)
Simplify if condition in cronjob tutorial
1 parent bb588c3 commit a7a3f72

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,7 @@ var _ = Describe("CronJob controller", func() {
115115
// We'll need to retry getting this newly created CronJob, given that creation may not immediately happen.
116116
Eventually(func() bool {
117117
err := k8sClient.Get(ctx, cronjobLookupKey, createdCronjob)
118-
if err != nil {
119-
return false
120-
}
121-
return true
118+
return err == nil
122119
}, timeout, interval).Should(BeTrue())
123120
// Let's make sure our Schedule string value was properly converted/handled.
124121
Expect(createdCronjob.Spec.Schedule).Should(Equal("1 * * * *"))

hack/docs/internal/cronjob-tutorial/writing_tests_controller.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,7 @@ var _ = Describe("CronJob controller", func() {
134134
// We'll need to retry getting this newly created CronJob, given that creation may not immediately happen.
135135
Eventually(func() bool {
136136
err := k8sClient.Get(ctx, cronjobLookupKey, createdCronjob)
137-
if err != nil {
138-
return false
139-
}
140-
return true
137+
return err == nil
141138
}, timeout, interval).Should(BeTrue())
142139
// Let's make sure our Schedule string value was properly converted/handled.
143140
Expect(createdCronjob.Spec.Schedule).Should(Equal("1 * * * *"))

0 commit comments

Comments
 (0)