mock

package
v1.1.0-alpha.2....-a910db8 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package mock provides fake OAM resources for use in tests.

Index

Constants

This section is empty.

Variables

View Source
var GV = schema.GroupVersion{Group: "g", Version: "v"}

GV returns a mock schema.GroupVersion.

Functions

func GVK

GVK returns the mock GVK of the given object.

func SchemeWith

func SchemeWith(o ...runtime.Object) *runtime.Scheme

SchemeWith returns a scheme with list of `runtime.Object`s registered.

Types

type Conditioned

type Conditioned struct{ Conditions []v1alpha1.Condition }

Conditioned is a mock that implements Conditioned interface.

func (*Conditioned) GetCondition

func (m *Conditioned) GetCondition(ct v1alpha1.ConditionType) v1alpha1.Condition

GetCondition get the Condition with the given ConditionType.

func (*Conditioned) SetConditions

func (m *Conditioned) SetConditions(c ...v1alpha1.Condition)

SetConditions sets the Conditions.

type DiscoveryMapper

type DiscoveryMapper struct {
	MockGetMapper    GetMapper
	MockRefresh      Refresh
	MockRESTMapping  RESTMapping
	MockKindsFor     KindsFor
	MockResourcesFor ResourcesFor
}

DiscoveryMapper for unit test only, use GetMapper and refresh will panic

func NewMockDiscoveryMapper

func NewMockDiscoveryMapper() *DiscoveryMapper

NewMockDiscoveryMapper for unit test only

func (*DiscoveryMapper) GetMapper

func (m *DiscoveryMapper) GetMapper() (meta.RESTMapper, error)

GetMapper for mock

func (*DiscoveryMapper) KindsFor

KindsFor for mock

func (*DiscoveryMapper) RESTMapping

func (m *DiscoveryMapper) RESTMapping(gk schema.GroupKind, versions ...string) (*meta.RESTMapping, error)

RESTMapping for mock

func (*DiscoveryMapper) Refresh

func (m *DiscoveryMapper) Refresh() (meta.RESTMapper, error)

Refresh for mock

func (*DiscoveryMapper) ResourcesFor

ResourcesFor for mock

type GetMapper

type GetMapper func() (meta.RESTMapper, error)

GetMapper is func type for mock convenience

type KindsFor

type KindsFor func(input schema.GroupVersionResource) ([]schema.GroupVersionKind, error)

KindsFor is func type for mock convenience

func NewMockKindsFor

func NewMockKindsFor(kind string, version ...string) KindsFor

NewMockKindsFor for unit test only

type ManagedResourceReferencer

type ManagedResourceReferencer struct{ Ref *corev1.ObjectReference }

ManagedResourceReferencer is a mock that implements ManagedResourceReferencer interface.

func (*ManagedResourceReferencer) GetResourceReference

func (m *ManagedResourceReferencer) GetResourceReference() *corev1.ObjectReference

GetResourceReference gets the ResourceReference.

func (*ManagedResourceReferencer) SetResourceReference

func (m *ManagedResourceReferencer) SetResourceReference(r *corev1.ObjectReference)

SetResourceReference sets the ResourceReference.

type Manager

type Manager struct {
	manager.Manager

	Client client.Client
	Scheme *runtime.Scheme
}

Manager is a mock object that satisfies manager.Manager interface.

func (*Manager) GetClient

func (m *Manager) GetClient() client.Client

GetClient returns the client.

func (*Manager) GetConfig

func (m *Manager) GetConfig() *rest.Config

GetConfig returns the config for test.

func (*Manager) GetScheme

func (m *Manager) GetScheme() *runtime.Scheme

GetScheme returns the scheme.

type NotFoundErr

type NotFoundErr struct {
	NotFoundStatus metav1.Status
}

NotFoundErr describes NotFound Resource error

func NewMockNotFoundErr

func NewMockNotFoundErr() NotFoundErr

NewMockNotFoundErr return a mock NotFoundErr

func (NotFoundErr) Error

func (mock NotFoundErr) Error() string

Error return error info

func (NotFoundErr) Status

func (mock NotFoundErr) Status() metav1.Status

Status returns the Status Reason

type Object

type Object struct {
	metav1.ObjectMeta
	runtime.Object
}

Object is a mock that implements Object interface.

func (*Object) DeepCopyObject

func (o *Object) DeepCopyObject() runtime.Object

DeepCopyObject returns a copy of the object as runtime.Object

func (*Object) GetObjectKind

func (o *Object) GetObjectKind() schema.ObjectKind

GetObjectKind returns schema.ObjectKind.

type RESTMapping

type RESTMapping func(gk schema.GroupKind, versions ...string) (*meta.RESTMapping, error)

RESTMapping is func type for mock convenience

func NewMockRESTMapping

func NewMockRESTMapping(resource string) RESTMapping

NewMockRESTMapping for unit test only

type Refresh

type Refresh func() (meta.RESTMapper, error)

Refresh is func type for mock convenience

type ResourcesFor

type ResourcesFor func(input schema.GroupVersionKind) (schema.GroupVersionResource, error)

ResourcesFor is func type for mock convenience

type Trait

type Trait struct {
	metav1.ObjectMeta
	runtime.Object
	v1alpha1.ConditionedStatus
	WorkloadReferencer
}

Trait is a mock that implements Trait interface.

func (*Trait) DeepCopyObject

func (t *Trait) DeepCopyObject() runtime.Object

DeepCopyObject returns a copy of the object as runtime.Object

func (*Trait) GetObjectKind

func (t *Trait) GetObjectKind() schema.ObjectKind

GetObjectKind returns schema.ObjectKind.

type Workload

type Workload struct {
	metav1.ObjectMeta
	runtime.Object
	v1alpha1.ConditionedStatus
}

Workload is a mock that implements Workload interface.

func (*Workload) DeepCopyObject

func (w *Workload) DeepCopyObject() runtime.Object

DeepCopyObject returns a copy of the object as runtime.Object

func (*Workload) GetObjectKind

func (w *Workload) GetObjectKind() schema.ObjectKind

GetObjectKind returns schema.ObjectKind.

type WorkloadReferencer

type WorkloadReferencer struct{ Ref v1alpha1.TypedReference }

A WorkloadReferencer references an OAM Workload type.

func (*WorkloadReferencer) GetWorkloadReference

func (w *WorkloadReferencer) GetWorkloadReference() v1alpha1.TypedReference

GetWorkloadReference gets the WorkloadReference.

func (*WorkloadReferencer) SetWorkloadReference

func (w *WorkloadReferencer) SetWorkloadReference(r v1alpha1.TypedReference)

SetWorkloadReference sets the WorkloadReference.

Jump to

Keyboard shortcuts

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