Documentation
¶
Overview ¶
Package helpers includes helper functions important for unit and integration testing.
Index ¶
- Constants
- type TestEnvironment
- func (t *TestEnvironment) Cleanup(ctx context.Context, objs ...client.Object) error
- func (t *TestEnvironment) CreateKubeconfigSecret(ctx context.Context, cluster *clusterv1.Cluster) error
- func (t *TestEnvironment) CreateNamespace(ctx context.Context, generateName string) (*corev1.Namespace, error)
- func (t *TestEnvironment) StartManager(ctx context.Context) error
- func (t *TestEnvironment) Stop() error
- func (*TestEnvironment) WaitForWebhooks()
Constants ¶
View Source
const ( // DefaultKindClusterName is the name for workload kind cluster. DefaultKindClusterName = "cso-kind-workload-cluster" // DefaultPodNamespace is default the namespace for the envtest resources. DefaultPodNamespace = "cso-system" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestEnvironment ¶
type TestEnvironment struct {
ctrl.Manager
client.Client
KubeConfig string
Config *rest.Config
WorkloadClusterClient *kubernetes.Clientset
AssetsClientFactory assetsclient.Factory
KubeClientFactory kubeclient.Factory
AssetsClient *assetsclientmocks.Client
KubeClient *kubemocks.Client
// contains filtered or unexported fields
}
TestEnvironment encapsulates a Kubernetes local test environment.
func NewTestEnvironment ¶
func NewTestEnvironment() *TestEnvironment
NewTestEnvironment creates a new environment spinning up a local api-server.
func (*TestEnvironment) CreateKubeconfigSecret ¶
func (t *TestEnvironment) CreateKubeconfigSecret(ctx context.Context, cluster *clusterv1.Cluster) error
CreateKubeconfigSecret generates a kubeconfig secret in a given capi cluster.
func (*TestEnvironment) CreateNamespace ¶
func (t *TestEnvironment) CreateNamespace(ctx context.Context, generateName string) (*corev1.Namespace, error)
CreateNamespace creates a namespace.
func (*TestEnvironment) StartManager ¶
func (t *TestEnvironment) StartManager(ctx context.Context) error
StartManager starts the manager and sets a cancel function into the testEnv object.
func (*TestEnvironment) Stop ¶
func (t *TestEnvironment) Stop() error
Stop stops the manager and cancels the context.
func (*TestEnvironment) WaitForWebhooks ¶
func (*TestEnvironment) WaitForWebhooks()
WaitForWebhooks waits for webhook port to be ready.
Click to show internal directories.
Click to hide internal directories.