testutil

package
v0.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2020 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultNamespace = "namespace"

DefaultNamespace is the namespace that objects will belong to.

Variables

This section is empty.

Functions

func AssertJSONEqual

func AssertJSONEqual(t *testing.T, expected, actual interface{})

AssertJSONEqual asserts two object's generated JSON is equal.

func CreateAppReplicaSet

func CreateAppReplicaSet(name string) *appsv1.ReplicaSet

CreateAppReplicaSet creates a replica set

func CreateCRD

func CreateCRD(name string, options ...CRDOption) *apiextv1beta1.CustomResourceDefinition

CreateCRD creates a CRD

func CreateClusterRole

func CreateClusterRole(name string) *rbacv1.ClusterRole

CreateClusterRole creates a cluster role.

func CreateClusterRoleBinding

func CreateClusterRoleBinding(name, roleName string, subjects []rbacv1.Subject) *rbacv1.ClusterRoleBinding

CreateClusterRoleBinding creates a cluster role binding

func CreateConfigMap

func CreateConfigMap(name string) *corev1.ConfigMap

CreateConfigMap creates a config map.

func CreateCronJob

func CreateCronJob(name string) *batchv1beta1.CronJob

func CreateCustomResource

func CreateCustomResource(name string) *unstructured.Unstructured

CreateCustomResource creates a custom resource.

func CreateDaemonSet

func CreateDaemonSet(name string) *appsv1.DaemonSet

CreateDaemonSet creates a daemon set

func CreateDeployment

func CreateDeployment(name string, options ...DeploymentOption) *appsv1.Deployment

CreateDeployment creates a deployment

func CreateEvent

func CreateEvent(name string) *corev1.Event

CreateEvent creates a event

func CreateExtReplicaSet

func CreateExtReplicaSet(name string) *extv1beta1.ReplicaSet

CreateExtReplicaSet creates a replica set

func CreateHorizontalPodAutoscaler

func CreateHorizontalPodAutoscaler(name string) *autoscalingv1.HorizontalPodAutoscaler

CreateHorizontalPodAutoscaler creates a horizontal pod autoscaler

func CreateIngress

func CreateIngress(name string) *extv1beta1.Ingress

CreateIngress creates an ingress

func CreateJob

func CreateJob(name string) *batchv1.Job

CreateJob creates a job

func CreateNamespace

func CreateNamespace(name string) *corev1.Namespace

CreateNamespace creates a namespace

func CreateNetworkPolicy added in v0.12.0

func CreateNetworkPolicy(name string) *networkingv1.NetworkPolicy

CreateNetworkPolicy creates a network policy

func CreateNode

func CreateNode(name string) *corev1.Node

CreateNode creates a node

func CreatePersistentVolume added in v0.11.0

func CreatePersistentVolume(name string) *corev1.PersistentVolume

CreatePersistentVolume creates a persistent volume

func CreatePersistentVolumeClaim

func CreatePersistentVolumeClaim(name string) *corev1.PersistentVolumeClaim

CreatePersistentVolumeClaim creates a persistent volume claim

func CreatePod

func CreatePod(name string, options ...PodOption) *corev1.Pod

CreatePod creates a pod

func CreatePodMetrics added in v0.10.0

func CreatePodMetrics(name string, options ...PodMetricOption) *metricsv1beta1.PodMetrics

func CreateReplicationController

func CreateReplicationController(name string) *corev1.ReplicationController

CreateReplicationController creates a replication controller

func CreateRole

func CreateRole(name string) *rbacv1.Role

CreateRole creates a role.

func CreateRoleBinding

func CreateRoleBinding(roleBindingName, roleName string, subjects []rbacv1.Subject) *rbacv1.RoleBinding

func CreateRoleBindingSubject

func CreateRoleBindingSubject(kind, name, namespace string) *rbacv1.Subject

func CreateSecret

func CreateSecret(name string, options ...func(*corev1.Secret)) *corev1.Secret

CreateSecret creates a secret

func CreateService

func CreateService(name string) *corev1.Service

CreateService creates a service

func CreateServiceAccount

func CreateServiceAccount(name string, options ...func(*corev1.ServiceAccount)) *corev1.ServiceAccount

CreateServiceAccount creates a service account

func CreateStatefulSet

func CreateStatefulSet(name string) *appsv1.StatefulSet

CreateStatefulSet creates a stateful set

func CreateTimestamp

func CreateTimestamp() *metav1.Time

func LoadObjectFromFile

func LoadObjectFromFile(t *testing.T, objectFile string) runtime.Object

LoadObjectFromFile loads a file from the `testdata` directory. It will assign it a `default` namespace if one is not set.

func LoadTestData added in v0.13.0

func LoadTestData(t *testing.T, fileName string) []byte

LoadTestData loads a file in the testdata directory.

func LoadTypedObjectFromFile

func LoadTypedObjectFromFile(t *testing.T, objectFile string, into runtime.Object)

LoadTypedObjectFromFile loads a file from the `testdata` directory. It will assign it a `default` namespace if one is not set.

func LoadUnstructuredFromFile added in v0.10.0

func LoadUnstructuredFromFile(t *testing.T, objectFile string) *unstructured.Unstructured

LoadUnstructuredFromFile loads an object from a file in the in `testdata` directory. It will assign a `default` namespace if one is not set. This helper does not support multiple objects in a YAML file.

func RequireErrorOrNot added in v0.10.0

func RequireErrorOrNot(t *testing.T, wantErr bool, err error)

RequireErrorOrNot or not is a helper that requires an error or not.

func Time

func Time() time.Time

Time generates a test time

func ToOwnerReferences

func ToOwnerReferences(t *testing.T, object runtime.Object) []metav1.OwnerReference

ToOwnerReferences converts an object to owner references.

func ToUnstructured

func ToUnstructured(t *testing.T, object runtime.Object) *unstructured.Unstructured

ToUnstructured converts an object to an unstructured.

func ToUnstructuredList

func ToUnstructuredList(t *testing.T, objects ...runtime.Object) *unstructured.UnstructuredList

ToUnstructuredList converts a list of objects to a list of unstructured.

Types

type CRDOption

type CRDOption func(definition *apiextv1beta1.CustomResourceDefinition)

CRDOption is an option for configuring CreateCRD.

func WithGenericCRD

func WithGenericCRD() CRDOption

WithGenericCRD creates a crd with group/kind and one version

type DeploymentOption

type DeploymentOption func(d *appsv1.Deployment)

DeploymentOption is an option for configuration CreateDeployment.

func WithGenericDeployment

func WithGenericDeployment() DeploymentOption

type PodMetricOption added in v0.10.0

type PodMetricOption func(metrics *metricsv1beta1.PodMetrics)

type PodOption

type PodOption func(*corev1.Pod)

PodOption is an option for configuring CreatePod.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL