testutils

package
v0.0.0-...-bdc75bf Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitScheme

func InitScheme(t *testing.T) *runtime.Scheme

Types

type Action

type Action interface {
	Verb() string
	GVR() schema.GroupVersionResource
	Key() client.ObjectKey
}

func NewCreateAction

func NewCreateAction(key client.ObjectKey, gvr schema.GroupVersionResource) Action

func NewGetAction

func NewGetAction(key client.ObjectKey, gvr schema.GroupVersionResource) Action

type CreateAction

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

func (CreateAction) GVR

func (CreateAction) Key

func (a CreateAction) Key() client.ObjectKey

func (CreateAction) Object

func (a CreateAction) Object() client.Object

func (CreateAction) Verb

func (a CreateAction) Verb() string

type FakeClient

type FakeClient struct {

	// ReactionChain is the list of reactors that will be attempted for every
	// request in the order they are tried.
	ReactionChain []Reactor
	// contains filtered or unexported fields
}

FakeClient is inspired and taken from https://github.com/kubernetes/client-go/

func NewFakeClient

func NewFakeClient(scheme *runtime.Scheme, objs ...client.Object) *FakeClient

NewFakeClient returns a new fake client

func (*FakeClient) AddReactor

func (c *FakeClient) AddReactor(verb string, resource string, reaction ReactionFunc)

func (*FakeClient) Create

func (c *FakeClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error

func (*FakeClient) Delete

func (c *FakeClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error

func (*FakeClient) DeleteAllOf

func (c *FakeClient) DeleteAllOf(_ context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error

func (*FakeClient) Get

func (c *FakeClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error

func (*FakeClient) List

func (c *FakeClient) List(_ context.Context, list client.ObjectList, opts ...client.ListOption) error

func (*FakeClient) Patch

func (c *FakeClient) Patch(_ context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error

func (*FakeClient) RESTMapper

func (c *FakeClient) RESTMapper() meta.RESTMapper

func (*FakeClient) Scheme

func (c *FakeClient) Scheme() *runtime.Scheme

func (*FakeClient) Status

func (c *FakeClient) Status() client.StatusWriter

func (*FakeClient) Update

func (c *FakeClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error

type GetAction

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

func (GetAction) GVR

func (GetAction) Key

func (a GetAction) Key() client.ObjectKey

func (GetAction) Object

func (a GetAction) Object() client.Object

func (GetAction) Verb

func (a GetAction) Verb() string

type ReactionFunc

type ReactionFunc func(action Action) (handled bool, err error)

ReactionFunc is a function returning `handled` set to true if no further processing is required and an error if one needs to be raised

type Reactor

type Reactor interface {
	// Handles indicates whether or not this Reactor deals with a given
	// action.
	Handles(action Action) bool
	// React handles the action and returns results.  It may choose to
	// delegate by indicated handled=false.
	React(action Action) (handled bool, err error)
}

Reactor is an interface to allow the composition of reaction functions.

Jump to

Keyboard shortcuts

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