Skip to content

Commit f9e2ae1

Browse files
adrianludwinDirectXMan12
authored andcommitted
Add some very rudimentary testing tips
Adds basic pointers to an example in the reference section.
1 parent 1d9f3cb commit f9e2ae1

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

docs/book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868

6969
- [controller-gen CLI](./reference/controller-gen.md)
7070
- [Artifacts](./reference/artifacts.md)
71+
- [Writing controller tests](./reference/writing-tests.md)
7172

7273
---
7374

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Writing controller tests
2+
3+
Testing Kubernetes controller is a big subject, and the boilerplate testing
4+
files generated for you by kubebuilder are fairly minimal. Until more
5+
documentation has been written, your best bet to get started is to look at some
6+
existing examples, such as:
7+
8+
* Azure Databricks Operator: see their fully fleshed-out
9+
[`suite_test.go`](https://github.com/microsoft/azure-databricks-operator/blob/0f722a710fea06b86ecdccd9455336ca712bf775/controllers/suite_test.go)
10+
as well as any `*_test.go` file in that directory [like this
11+
one](https://github.com/microsoft/azure-databricks-operator/blob/0f722a710fea06b86ecdccd9455336ca712bf775/controllers/secretscope_controller_test.go).
12+
13+
The basic approach is that, in your generated `suite_test.go` file, you will
14+
create a local Kubernetes API server, instantiate and run your controllers, and
15+
then write additional `*_test.go` files to test it using
16+
[Ginko](http://onsi.github.io/ginkgo).

0 commit comments

Comments
 (0)