Skip to content

Commit 02b1d3f

Browse files
authored
Merge pull request #5269 from BadisLaffet1/docs/fix-writing-tests-duplicate-collapse
📖 (docs): Fix duplicate content and collapse markers in writing tests tutorial
2 parents db1aa93 + 94b882e commit 02b1d3f

File tree

7 files changed

+0
-35
lines changed

7 files changed

+0
-35
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ var _ = Describe("CronJob controller", func() {
208208

209209
})
210210

211-
// +kubebuilder:docs-gen:collapse=Remaining code from cronjob_controller_test.go
212-
213211
/*
214212
After writing all this code, you can run `go test ./...` in your `controllers/` directory again to run your new test!
215213
*/

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ var _ = AfterSuite(func() {
170170
Expect(err).NotTo(HaveOccurred())
171171
})
172172

173-
// +kubebuilder:docs-gen:collapse=Remaining code from suite_test.go
174-
175173
/*
176174
Now that you have your controller running on a test cluster and a client ready to perform operations on your CronJob, we can start writing integration tests!
177175
*/

docs/book/src/cronjob-tutorial/writing-tests.md

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,6 @@ The basic approach is that, in your generated `suite_test.go` file, you will use
99

1010
If you want to tinker with how your envtest cluster is configured, see section [Configuring envtest for integration tests](../reference/envtest.md) as well as the [`envtest docs`](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/envtest?tab=doc).
1111

12-
## Test Environment Setup
13-
14-
{{#literatego ../cronjob-tutorial/testdata/project/internal/controller/suite_test.go}}
15-
16-
## Testing your Controller's Behavior
17-
18-
{{#literatego ../cronjob-tutorial/testdata/project/internal/controller/cronjob_controller_test.go}}
19-
20-
This Status update example above demonstrates a general testing strategy for a custom Kind with downstream objects. By this point, you hopefully have learned the following methods for testing your controller behavior:
21-
22-
* Setting up your controller to run on an envtest cluster
23-
* Writing stubs for creating test objects
24-
* Isolating changes to an object to test specific controller behavior
25-
26-
# Writing controller tests
27-
28-
Testing Kubernetes controllers is a big subject, and the boilerplate testing
29-
files generated for you by kubebuilder are fairly minimal.
30-
31-
To walk you through integration testing patterns for Kubebuilder-generated controllers, we will revisit the CronJob we built in our first tutorial and write a simple test for it.
32-
33-
The basic approach is that, in your generated `suite_test.go` file, you will use envtest to create a local Kubernetes API server, instantiate and run your controllers, and then write additional `*_test.go` files to test it using [Ginkgo](http://onsi.github.io/ginkgo).
34-
35-
If you want to tinker with how your envtest cluster is configured, see section [Configuring envtest for integration tests](../reference/envtest.md) as well as the [`envtest docs`](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/envtest?tab=doc).
36-
3712
<aside class="note">
3813
<h1>Other Examples</h1>
3914

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ var _ = Describe("CronJob controller", func() {
208208

209209
})
210210

211-
// +kubebuilder:docs-gen:collapse=Remaining code from cronjob_controller_test.go
212-
213211
/*
214212
After writing all this code, you can run `go test ./...` in your `controllers/` directory again to run your new test!
215213
*/

docs/book/src/multiversion-tutorial/testdata/project/internal/controller/suite_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ var _ = AfterSuite(func() {
170170
Expect(err).NotTo(HaveOccurred())
171171
})
172172

173-
// +kubebuilder:docs-gen:collapse=Remaining code from suite_test.go
174-
175173
/*
176174
Now that you have your controller running on a test cluster and a client ready to perform operations on your CronJob, we can start writing integration tests!
177175
*/

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ var _ = Describe("CronJob controller", func() {
226226
})
227227
228228
})
229-
// +kubebuilder:docs-gen:collapse=Remaining code from cronjob_controller_test.go
230229
231230
/*
232231
After writing all this code, you can run` + " `" + `go test ./...` + "`" + ` in your` + " `" + `controllers/` + "`" + ` directory again to run your new test!

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ var _ = AfterSuite(func() {
120120
err := testEnv.Stop()
121121
Expect(err).NotTo(HaveOccurred())
122122
})
123-
// +kubebuilder:docs-gen:collapse=Remaining code from suite_test.go
124123
125124
/*
126125
Now that you have your controller running on a test cluster and a client ready to perform operations on your CronJob, we can start writing integration tests!

0 commit comments

Comments
 (0)