fake

package
v0.0.0-...-e048679 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockDecoder

type MockDecoder struct {
	// DecodeFunc mocks the Decode method.
	DecodeFunc func(req admission.Request, into runtime.Object) error

	// DecodeRawFunc mocks the DecodeRaw method.
	DecodeRawFunc func(rawObj runtime.RawExtension, into runtime.Object) error
	// contains filtered or unexported fields
}

MockDecoder is a mock implementation of handlers.Decoder.

func TestSomethingThatUsesDecoder(t *testing.T) {

	// make and configure a mocked handlers.Decoder
	mockedDecoder := &MockDecoder{
		DecodeFunc: func(req admission.Request, into runtime.Object) error {
			panic("mock out the Decode method")
		},
		DecodeRawFunc: func(rawObj runtime.RawExtension, into runtime.Object) error {
			panic("mock out the DecodeRaw method")
		},
	}

	// use mockedDecoder in code that requires handlers.Decoder
	// and then make assertions.

}

func (*MockDecoder) Decode

func (mock *MockDecoder) Decode(req admission.Request, into runtime.Object) error

Decode calls DecodeFunc.

func (*MockDecoder) DecodeCalls

func (mock *MockDecoder) DecodeCalls() []struct {
	Req  admission.Request
	Into runtime.Object
}

DecodeCalls gets all the calls that were made to Decode. Check the length with:

len(mockedDecoder.DecodeCalls())

func (*MockDecoder) DecodeRaw

func (mock *MockDecoder) DecodeRaw(rawObj runtime.RawExtension, into runtime.Object) error

DecodeRaw calls DecodeRawFunc.

func (*MockDecoder) DecodeRawCalls

func (mock *MockDecoder) DecodeRawCalls() []struct {
	RawObj runtime.RawExtension
	Into   runtime.Object
}

DecodeRawCalls gets all the calls that were made to DecodeRaw. Check the length with:

len(mockedDecoder.DecodeRawCalls())

type MockHandler

type MockHandler struct {
	// HandleFunc mocks the Handle method.
	HandleFunc func(ctx context.Context, pod *corev1.Pod, namespace string) error
	// contains filtered or unexported fields
}

MockHandler is a mock implementation of handlers.K8sHandler.

func TestSomethingThatUsesK8sHandler(t *testing.T) {

	// make and configure a mocked handlers.K8sHandler
	mockedK8sHandler := &MockHandler{
		HandleFunc: func(ctx context.Context, pod *corev1.Pod, namespace string) error {
			panic("mock out the Handle method")
		},
	}

	// use mockedK8sHandler in code that requires handlers.K8sHandler
	// and then make assertions.

}

func (*MockHandler) Handle

func (mock *MockHandler) Handle(ctx context.Context, pod *corev1.Pod, namespace string) error

Handle calls HandleFunc.

func (*MockHandler) HandleCalls

func (mock *MockHandler) HandleCalls() []struct {
	Ctx       context.Context
	Pod       *corev1.Pod
	Namespace string
}

HandleCalls gets all the calls that were made to Handle. Check the length with:

len(mockedK8sHandler.HandleCalls())

Jump to

Keyboard shortcuts

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