testing

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConditionIsReady added in v0.7.0

func ConditionIsReady(condition *apis.Condition) error

ConditionIsReady returns an error if the condition status is not True useful for Eventually checks

func DefaultConvertRuntimeToClientobjectFunc added in v0.7.0

func DefaultConvertRuntimeToClientobjectFunc(runtimeObj runtime.Object) (obj client.Object, err error)

DefaultConvertRuntimeToClientobjectFunc convert runtime.Object to client.Object be similar to convertFromUnstructuredIfNecessary

func DeleteResources

func DeleteResources(file string, clt client.Client) (err error)

DeleteResources delete resources contained in the file

func LoadJSON added in v0.7.0

func LoadJSON(file string, obj interface{}) (err error)

LoadJSON loads json

func LoadKubeResources

func LoadKubeResources(file string, clt client.Client, converts ...ConvertRuntimeObjctToClientObjectFunc) (err error)

LoadKubeResources loading kubernetes resources

func LoadKubeResourcesAsUnstructured

func LoadKubeResourcesAsUnstructured(file string) (objs []unstructured.Unstructured, err error)

func LoadMultiYamlOrJson added in v0.7.0

func LoadMultiYamlOrJson[T any](file string, list *[]T) (err error)

LoadMultiYamlOrJson loads multi yamls

func LoadObjectOrDie

func LoadObjectOrDie(g *WithT, file string, obj metav1.Object, patches ...func(metav1.Object)) metav1.Object

LoadObjectOrDie loads object from yaml and returns

func LoadObjectReferenceOrDie

func LoadObjectReferenceOrDie(g *WithT, file string, obj *corev1.ObjectReference, patches ...func(*corev1.ObjectReference)) *corev1.ObjectReference

LoadObjectReferenceOrDie loads object reference from yaml and returns

func LoadResourceFromFile

func LoadResourceFromFile(scheme *runtime.Scheme, path string) (obj runtime.Object, err error)

func LoadResourcesFromFile

func LoadResourcesFromFile(scheme *runtime.Scheme, path string) (objs []runtime.Object, err error)

func LoadYAML

func LoadYAML(file string, obj interface{}) (err error)

LoadYAML loads yaml

func MustLoadFileString added in v0.7.0

func MustLoadFileString(file string, content *string)

MustLoadFileString loads a file as string will panic if if failes ONLY FOR TEST USAGE

func MustLoadJSON added in v0.7.0

func MustLoadJSON(file string, obj interface{})

MustLoadJSON loads json or panics if the parse fails.

func MustLoadMultiYamlOrJson added in v0.7.0

func MustLoadMultiYamlOrJson[T any](file string, list *[]T)

MustLoadMultiYamlOrJson loads multi yamls or panics if the parse fails.

func MustLoadReturnObjectFromYAML added in v0.7.0

func MustLoadReturnObjectFromYAML(file string, obj interface{}) interface{}

MustLoadReturnObjectFromYAML loads and object from yaml file and returns as interface{} if any loading errors happen will panic TO BE USED IN TESTS, DO NOT USE IN PRODUCTION CODE

func MustLoadYaml added in v0.7.0

func MustLoadYaml(file string, obj interface{})

MustLoadYaml loads yaml or panics if the parse fails.

func NewTestManager added in v0.7.0

func NewTestManager(data map[string]string) config.Manager

func RuntimeObjectFromUnstructured

func RuntimeObjectFromUnstructured(scheme *runtime.Scheme, u *unstructured.Unstructured) (runtime.Object, error)

RuntimeObjectFromUnstructured converts an unstructured to a runtime object

func SetName

func SetName(name string) func(metav1.Object)

func ToObjectList added in v0.7.0

func ToObjectList[T client.Object](list []T) []client.Object

ToObjectList converts resource list to a list of client.Object

func UnstructedToTyped

func UnstructedToTyped(from unstructured.Unstructured, to interface{}) error

UnstructedToTyped converts an unstructured object into a object Warning: This SHOULD never be used in production code, only in test code

func WarningOnError

func WarningOnError(logger *zap.SugaredLogger, err error, message string)

WarningOnError set a warning on error

Types

type ConditionBuilder

type ConditionBuilder struct {
	apis.Condition
}

ConditionBuilder builds a conditions in a builder pattern

func BuildCondition

func BuildCondition() *ConditionBuilder

BuildCondition starts a condition builder object useful for unit tests that require validating multiple conditions

func (*ConditionBuilder) Done

func (c *ConditionBuilder) Done() *apis.Condition

SetReasonMessage returns a condition

func (*ConditionBuilder) SetReasonMessage

func (c *ConditionBuilder) SetReasonMessage(reason, message string, formtKeyValues ...interface{}) *ConditionBuilder

SetReasonMessage sets the message for the condition

func (*ConditionBuilder) SetStatus

SetStatus sets the status for the condition

func (*ConditionBuilder) SetType

SetType sets the type for the condition

type ConvertRuntimeObjctToClientObjectFunc added in v0.3.0

type ConvertRuntimeObjctToClientObjectFunc func(runtime.Object) (client.Object, error)

Directories

Path Synopsis
Package mock contains useful functionality for testing
Package mock contains useful functionality for testing
github.com/katanomi/pkg
Package sharedmain is a generated GoMock package.
Package sharedmain is a generated GoMock package.
github.com/katanomi/pkg/apis/meta/v1alpha1
Package apis is a generated GoMock package.
Package apis is a generated GoMock package.
github.com/katanomi/pkg/conditioner
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
github.com/katanomi/pkg/multicluster
Package multicluster is a generated GoMock package.
Package multicluster is a generated GoMock package.
github.com/katanomi/pkg/plugin/client
Package client is a generated GoMock package.
Package client is a generated GoMock package.
github.com/katanomi/pkg/plugin/storage
Package storage is a generated GoMock package.
Package storage is a generated GoMock package.
github.com/katanomi/pkg/plugin/storage/capabilities/archive/v1alpha1
Package v1alpha1 is a generated GoMock package.
Package v1alpha1 is a generated GoMock package.
github.com/katanomi/pkg/plugin/storage/capabilities/filestore/v1alpha1
Package v1alpha1 is a generated GoMock package.
Package v1alpha1 is a generated GoMock package.
github.com/katanomi/pkg/plugin/storage/client
Package v1alpha1 is a generated GoMock package.
Package v1alpha1 is a generated GoMock package.
github.com/katanomi/pkg/plugin/storage/client/versioned/archive/v1alpha1
Package v1alpha1 is a generated GoMock package.
Package v1alpha1 is a generated GoMock package.
github.com/katanomi/pkg/plugin/storage/client/versioned/filestore/v1alpha1
Package v1alpha1 is a generated GoMock package.
Package v1alpha1 is a generated GoMock package.
github.com/katanomi/pkg/webhook/admission
Package admission is a generated GoMock package.
Package admission is a generated GoMock package.
github.com/minio/minio-go
Package pkg is a generated GoMock package.
Package pkg is a generated GoMock package.
k8s.io/client-go/kubernetes
Package kubernetes is a generated GoMock package.
Package kubernetes is a generated GoMock package.
knative.dev/pkg/apis
Package apis is a generated GoMock package.
Package apis is a generated GoMock package.
sigs.k8s.io/controller-runtime/pkg/client
Package client is a generated GoMock package.
Package client is a generated GoMock package.
sigs.k8s.io/controller-runtime/pkg/manager
Package manager is a generated GoMock package.
Package manager is a generated GoMock package.

Jump to

Keyboard shortcuts

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