Documentation
¶
Overview ¶
Package testenv wraps controller-runtime's envtest.Environment with helpers common to integration tests that exercise a real kube-apiserver + etcd: lifecycle, kubeconfig file shim, per-test namespace creation.
The package is intentionally seictl-agnostic — pure K8s plumbing. sei-protocol/platform#118 tracks adding envtest to sei-k8s-controller; when that lands, the natural extraction is to a shared sei-protocol/sei-k8s-testkit module that both repos consume.
Requires KUBEBUILDER_ASSETS pointing at a setup-envtest binary directory. Callers without it should set it via `make test-envtest` or the equivalent CI step before invoking `go test`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env is a started envtest environment. Call Stop in test cleanup.
func Start ¶
Start spins up an envtest.Environment. Designed for TestMain — callers invoke Stop() themselves before exiting. For per-test bootstrap (rare; prefer one Start per package via TestMain), a separate helper would register t.Cleanup.
Returns an actionable error if KUBEBUILDER_ASSETS is unset; the binary fetch is the harness's job (Makefile / CI), not the test's.
func (*Env) RESTConfig ¶
RESTConfig returns a config pointing at the test apiserver. The returned pointer is owned by envtest; treat it as read-only.
func (*Env) UniqueNamespace ¶
UniqueNamespace creates a namespace named `<prefix>-<test-id>` and returns its name. No cleanup is registered — Stop() drops the whole apiserver, so per-namespace teardown adds latency for no benefit.
type Option ¶
type Option func(*envtest.Environment)
Option configures the underlying envtest.Environment before Start.
func WithCRDPaths ¶
WithCRDPaths registers CRD YAML files at the given paths so envtest installs them before tests run.