Add testing.md doc to describe where specific tests should be added

This commit is contained in:
Volodymyr Zotov
2025-08-26 16:50:06 -05:00
parent b1b6c97a88
commit d75a33d524

26
docs/testing.md Normal file
View File

@@ -0,0 +1,26 @@
# Testing
## Unit tests
**When**: Pure Go logic, no Kubernetes apiserver or network.
**Where**: `internal/...`, `pkg/...`
**Add files in**: `*_test.go` next to the code.
**Run**: `make test`
## Integration tests (envtest)
**When**: Controller/reconciler behavior against a mocked kubernetes cluster.
**Where**: `internal/controller/...`
**Framework**: controller-runtimes `envtest`.
**Run**: `make test`
## E2E tests (kind)
**When**: Full cluster behavior (CRDs, operator image, Connect/SA flows).
**Where**: `test/e2e/...`
**Framework**: Ginkgo + `pkg/testhelper`.
**Local prep**:
1. [Install `kind`](https://kind.sigs.k8s.io/docs/user/quick-start/#installing-with-a-package-manager) to spin up local Kubernetes cluster.
2. `export OP_CONNECT_TOKEN=<token>`
3. `export OP_SERVICE_ACCOUNT_TOKEN=<token>`
4. `make test-e2e`
**Run**: `make test-e2e`