clientsholder

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2022 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearTestClientsHolder

func ClearTestClientsHolder()

func SetupFakeOlmClient

func SetupFakeOlmClient(olmMockObjects []runtime.Object)

SetupFakeOlmClient Overrides the OLM client with the fake interface object for unit testing. Loads the mocking objects so olmv interface methods can find them.

Types

type ClientsHolder

type ClientsHolder struct {
	RestConfig    *rest.Config
	DynamicClient dynamic.Interface
	APIExtClient  apiextv1.Interface
	OlmClient     olmClient.Interface
	OcpClient     clientconfigv1.ConfigV1Interface
	K8sClient     kubernetes.Interface
	MachineCfg    ocpMachine.Interface
	// contains filtered or unexported fields
}

func GetClientsHolder

func GetClientsHolder(filenames ...string) *ClientsHolder

GetClientsHolder returns the singleton ClientsHolder object.

func GetTestClientsHolder

func GetTestClientsHolder(k8sMockObjects []runtime.Object, filenames ...string) *ClientsHolder

GetTestClientHolder Overwrites the existing clientholders with a mocked version for unit testing. Only pure k8s interfaces will be available. The runtime objects must be pure k8s ones. For other (OLM, ) runtime mocking objects loading, use the proper clientset mocking function.

func (*ClientsHolder) ExecCommandContainer

func (clientsholder *ClientsHolder) ExecCommandContainer(
	ctx Context, command string) (stdout, stderr string, err error)

ExecCommand runs command in the pod and returns buffer output.

type Command

type Command interface {
	ExecCommandContainer(Context, string) (string, string, error)
}

type CommandMock

type CommandMock struct {
	// ExecCommandContainerFunc mocks the ExecCommandContainer method.
	ExecCommandContainerFunc func(context Context, s string) (string, string, error)
	// contains filtered or unexported fields
}

CommandMock is a mock implementation of Command.

func TestSomethingThatUsesCommand(t *testing.T) {

	// make and configure a mocked Command
	mockedCommand := &CommandMock{
		ExecCommandContainerFunc: func(context Context, s string) (string, string, error) {
			panic("mock out the ExecCommandContainer method")
		},
	}

	// use mockedCommand in code that requires Command
	// and then make assertions.

}

func (*CommandMock) ExecCommandContainer

func (mock *CommandMock) ExecCommandContainer(context Context, s string) (string, string, error)

ExecCommandContainer calls ExecCommandContainerFunc.

func (*CommandMock) ExecCommandContainerCalls

func (mock *CommandMock) ExecCommandContainerCalls() []struct {
	Context Context
	S       string
}

ExecCommandContainerCalls gets all the calls that were made to ExecCommandContainer. Check the length with:

len(mockedCommand.ExecCommandContainerCalls())

type Context

type Context struct {
	Namespace     string
	Podname       string
	Containername string
}

Jump to

Keyboard shortcuts

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