Documentation ¶
Overview ¶
Package fakekubeapi contains a *very* simple httptest.Server that can be used to stand in for a real Kube API server in tests.
Usage:
func TestSomething(t *testing.T) { resources := map[string]kubeclient.Object{ // store preexisting resources here "/api/v1/namespaces/default/pods/some-pod-name": &corev1.Pod{...}, } server, restConfig := fakekubeapi.Start(t, resources) defer server.Close() client := kubeclient.New(kubeclient.WithConfig(restConfig)) // do stuff with client... }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Start ¶
func Start(t *testing.T, resources map[string]runtime.Object) (*httptest.Server, *restclient.Config)
Start starts an httptest.Server (with TLS) that pretends to be a Kube API server.
The server uses the provided resources map to store API Object's. The map should be from API path to Object (e.g., /api/v1/namespaces/default/pods/some-pod-name => &corev1.Pod{}).
Start returns an already started httptest.Server and a restclient.Config that can be used to talk to the server.
Note! Only these following verbs are (partially) supported: create, get, update, delete.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.