mock

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnError = errors.New("mock.AnError general error for testing") //nolint

AnError is a general error for testing.

View Source
var ErrWriter = errors.New("mock error")

ErrWriter is a fixed message returned by `ErrorWriter.Write`.

Functions

func ConfigMap

func ConfigMap(name string, namespace string, data map[string]string) *corev1.ConfigMap

ConfigMap returns a mock struct.

func Container

func Container(env map[string]string, configmaps, secrets []string) corev1.Container

Container returns a mock struct.

func CronJobv1

func CronJobv1(name, namespace string, env map[string]string, configmaps, secrets []string) *batchv1.CronJob

CronJobv1 returns a mock struct.

func CronJobv1Resource added in v1.2.0

func CronJobv1Resource() *metav1.APIResourceList

CronJobv1Resource returns a v1 CronJob resource list.

func CronJobv1beta1

func CronJobv1beta1(name, namespace string, env map[string]string, configmaps, secrets []string) *batchv1beta1.CronJob

CronJobv1beta1 returns a mock struct.

func CronJobv1beta1Resource added in v1.2.0

func CronJobv1beta1Resource() *metav1.APIResourceList

CronJobv1beta1Resource returns a v1beta1 CronJob resource list.

func DaemonSet

func DaemonSet(name, namespace string, env map[string]string, configmaps, secrets []string) *appsv1.DaemonSet

DaemonSet returns a mock struct.

func Deployment

func Deployment(name, namespace string, env map[string]string, configmaps, secrets []string) *appsv1.Deployment

Deployment returns a mock struct.

func InvalidGroupResource added in v1.2.0

func InvalidGroupResource() *metav1.APIResourceList

InvalidGroupResource returns an `APIResourceList` with an invalid group.

func Job

func Job(name, namespace string, env map[string]string, configmaps, secrets []string) *batchv1.Job

Job returns a mock struct.

func Jobv1Resource added in v1.2.0

func Jobv1Resource() *metav1.APIResourceList

Jobv1Resource returns a v1 Job resource list.

func Namespace

func Namespace(name string) *corev1.Namespace

Namespace returns a mock struct.

func NewFakeResource added in v1.2.0

func NewFakeResource(groupVersion, name, singularName, kind, group string) *metav1.APIResourceList

NewFakeResource returns an `APIResourceList` to be used with `FakeClient.WithResources`.

func Pod

func Pod(name, namespace string, env map[string]string, configmaps, secrets []string) *corev1.Pod

Pod returns a mock struct.

func ReplicaSet

func ReplicaSet(name, namespace string, env map[string]string, configmaps, secrets []string) *appsv1.ReplicaSet

ReplicaSet returns a mock struct.

func Secret

func Secret(name string, namespace string, data map[string][]byte) *corev1.Secret

Secret returns a mock struct.

func StatefulSet added in v1.3.0

func StatefulSet(name, namespace string, env map[string]string, configmaps, secrets []string) *appsv1.StatefulSet

StatefulSet returns a mock struct.

func UnsupportedGroupResource added in v1.2.0

func UnsupportedGroupResource() *metav1.APIResourceList

UnsupportedGroupResource returns a resource list with a group version `batch/unsupported`.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is used in tests.

func NewError

func NewError(message string) *Error

NewError constructor.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

type ErrorWriter added in v1.2.0

type ErrorWriter struct {
	// contains filtered or unexported fields
}

ErrorWriter used in tests.

func NewErrorWriter added in v1.2.0

func NewErrorWriter() *ErrorWriter

NewErrorWriter creates an io.Writer used in tests.

func (*ErrorWriter) ErrorAfter added in v1.2.0

func (w *ErrorWriter) ErrorAfter(errorAfter int) io.Writer

ErrorAfter will cause the writer to error after a certain number of writes.

func (*ErrorWriter) Write added in v1.2.0

func (w *ErrorWriter) Write(p []byte) (int, error)

Write will return 0 for length and after `errorAfter` is hit, will start returning `ErrWriter`.

type FakeClient added in v1.2.0

type FakeClient struct {
	*fake.Clientset
}

FakeClient used in tests.

func NewFakeClient added in v1.2.0

func NewFakeClient(objects ...runtime.Object) *FakeClient

NewFakeClient returns a `FakeClient` with a `fake.ClientSet` internally.

func (*FakeClient) PrependReactor added in v1.2.0

func (c *FakeClient) PrependReactor(v string, r string, h bool, o runtime.Object, e error) *FakeClient

PrependReactor adds a reactor to the beginning of the chain.

func (*FakeClient) WithResources added in v1.2.0

func (c *FakeClient) WithResources(resourceList *metav1.APIResourceList) *FakeClient

WithResources adds an `APIResourceList` to a `FakeClient`.

type Writer added in v1.2.0

type Writer struct {
	// contains filtered or unexported fields
}

Writer used in tests.

func NewWriter added in v1.2.0

func NewWriter() *Writer

NewWriter creates an io.Writer used in tests.

func (*Writer) String added in v1.2.0

func (w *Writer) String() string

String implements `Stringer`.

func (*Writer) Write added in v1.2.0

func (w *Writer) Write(p []byte) (int, error)

Write bytes.

Jump to

Keyboard shortcuts

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