Skip to content

Commit

Permalink
Add some very rudimentary testing tips
Browse files Browse the repository at this point in the history
Adds basic pointers to an example in the reference section.
  • Loading branch information
adrianludwin authored and DirectXMan12 committed Sep 16, 2019
1 parent 1d9f3cb commit f9e2ae1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@

- [controller-gen CLI](./reference/controller-gen.md)
- [Artifacts](./reference/artifacts.md)
- [Writing controller tests](./reference/writing-tests.md)

---

Expand Down
16 changes: 16 additions & 0 deletions docs/book/src/reference/writing-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Writing controller tests

Testing Kubernetes controller is a big subject, and the boilerplate testing
files generated for you by kubebuilder are fairly minimal. Until more
documentation has been written, your best bet to get started is to look at some
existing examples, such as:

* Azure Databricks Operator: see their fully fleshed-out
[`suite_test.go`](https://github.com/microsoft/azure-databricks-operator/blob/0f722a710fea06b86ecdccd9455336ca712bf775/controllers/suite_test.go)
as well as any `*_test.go` file in that directory [like this
one](https://github.com/microsoft/azure-databricks-operator/blob/0f722a710fea06b86ecdccd9455336ca712bf775/controllers/secretscope_controller_test.go).

The basic approach is that, in your generated `suite_test.go` file, you will
create a local Kubernetes API server, instantiate and run your controllers, and
then write additional `*_test.go` files to test it using
[Ginko](http://onsi.github.io/ginkgo).

0 comments on commit f9e2ae1

Please sign in to comment.