mock

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotInTestMode = errors.New("mock persister is not in test mode")

Functions

func Identify

func Identify(name, namespace string, gvk schema.GroupVersionKind, subPath string) resourceIdentifier

Identify generates the struct used as key for the internal storage.

func New

func New(mockCfg *config.MockConfiguration, testMode bool) (persist.Persister, error)

New creates a new MockPersister.

Types

type ErrUnexpectedCall

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

func (*ErrUnexpectedCall) Error

func (e *ErrUnexpectedCall) Error() string

type ErrUnexpectedReturn

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

func (*ErrUnexpectedReturn) Error

func (e *ErrUnexpectedReturn) Error() string

type MockPersister

type MockPersister struct {
	Storage map[resourceIdentifier]*unstructured.Unstructured
	// contains filtered or unexported fields
}

MockPersister stores resources in memory and logs operations on it. It does not actually persist anything.

func (*MockPersister) ClearExpectedCalls

func (p *MockPersister) ClearExpectedCalls() []*MockedCall

func (*MockPersister) Delete

func (p *MockPersister) Delete(ctx context.Context, name, namespace string, gvk schema.GroupVersionKind, subPath string) error

func (*MockPersister) Exists

func (p *MockPersister) Exists(ctx context.Context, name, namespace string, gvk schema.GroupVersionKind, subPath string) (bool, error)

func (*MockPersister) ExpectCall

func (p *MockPersister) ExpectCall(expected *MockedCall, expectedReturn *MockedReturn)

func (*MockPersister) Get

func (p *MockPersister) Get(ctx context.Context, name, namespace string, gvk schema.GroupVersionKind, subPath string) (*unstructured.Unstructured, error)

func (*MockPersister) InjectLogger

func (p *MockPersister) InjectLogger(il *logging.Logger)

func (*MockPersister) InternalPersister

func (p *MockPersister) InternalPersister() persist.Persister

func (*MockPersister) IsExpectingCalls

func (p *MockPersister) IsExpectingCalls() bool

func (*MockPersister) Persist

type MockedCall

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

func MockedDeleteCall

func MockedDeleteCall(name, namespace string, gvk schema.GroupVersionKind, subPath string) *MockedCall

func MockedExistsCall

func MockedExistsCall(name, namespace string, gvk schema.GroupVersionKind, subPath string) *MockedCall

func MockedGetCall

func MockedGetCall(name, namespace string, gvk schema.GroupVersionKind, subPath string) *MockedCall

func MockedPersistCall

func MockedPersistCall(resource *unstructured.Unstructured, t persist.Transformer, subPath string) *MockedCall

type MockedReturn

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

func MockedDeleteReturn

func MockedDeleteReturn(err error) *MockedReturn

func MockedExistsReturn

func MockedExistsReturn(exists bool, err error) *MockedReturn

func MockedGetReturn

func MockedGetReturn(resource *unstructured.Unstructured, err error) *MockedReturn

func MockedPersistReturn

func MockedPersistReturn(resource *unstructured.Unstructured, changed bool, err error) *MockedReturn

Jump to

Keyboard shortcuts

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