Documentation ¶
Index ¶
- Constants
- func ClearTestClientsHolder()
- func GetClientConfigFromRestConfig(restConfig *rest.Config) *clientcmdapi.Config
- func SetTestK8sClientsHolder(k8sClient kubernetes.Interface)
- func SetupFakeOlmClient(olmMockObjects []runtime.Object)
- type ClientsHolder
- type Command
- type CommandMock
- type Context
Constants ¶
const (
DefaultTimeout = 10 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
func ClearTestClientsHolder ¶
func ClearTestClientsHolder()
func GetClientConfigFromRestConfig ¶
func GetClientConfigFromRestConfig(restConfig *rest.Config) *clientcmdapi.Config
Creates a clientcmdapi.Config object from a rest.Config. Based on https://github.com/kubernetes/client-go/issues/711#issuecomment-1666075787
func SetTestK8sClientsHolder ¶
func SetTestK8sClientsHolder(k8sClient kubernetes.Interface)
func SetupFakeOlmClient ¶
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 ScalingClient scale.ScalesGetter APIExtClient apiextv1.Interface OlmClient olmClient.Interface OlmPkgClient olmpkgclient.OperatorsV1Interface OcpClient clientconfigv1.ConfigV1Interface K8sClient kubernetes.Interface K8sNetworkingClient networkingv1.NetworkingV1Interface CNCFNetworkingClient cncfNetworkAttachmentv1.Interface SriovNetworkingClient sriovNetworkOp.SriovnetworkV1Interface DiscoveryClient discovery.DiscoveryInterface MachineCfg ocpMachine.Interface KubeConfig []byte GroupResources []*metav1.APIResourceList ApiserverClient apiserverscheme.Interface // contains filtered or unexported fields }
func GetClientsHolder ¶
func GetClientsHolder(filenames ...string) *ClientsHolder
GetClientsHolder returns the singleton ClientsHolder object.
func GetNewClientsHolder ¶
func GetNewClientsHolder(kubeconfigFile string) *ClientsHolder
func GetTestClientsHolder ¶
func GetTestClientsHolder(k8sMockObjects []runtime.Object) *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 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 ¶
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 {
// contains filtered or unexported fields
}