linuxmock

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SystemMock

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

SystemMock allows to mock netlink-related methods

func NewSystemMock

func NewSystemMock() *SystemMock

NewSystemMock creates new instance of the mock and initializes response list

func (*SystemMock) GetNamespaceFromName

func (mock *SystemMock) GetNamespaceFromName(name string) (netns.NsHandle, error)

GetNamespaceFromName implements NetNsNamespace.

func (*SystemMock) LinkSetNsFd

func (mock *SystemMock) LinkSetNsFd(link netlink.Link, fd int) error

LinkSetNsFd implements NetlinkNamespace.

func (*SystemMock) MkDirAll

func (mock *SystemMock) MkDirAll(path string, perm os.FileMode) error

MkDirAll implements OperatingSystem.

func (*SystemMock) Mount

func (mock *SystemMock) Mount(source string, target string, fsType string, flags uintptr, data string) error

Mount implements Syscall.

func (*SystemMock) NewNetworkNamespace

func (mock *SystemMock) NewNetworkNamespace() (netns.NsHandle, error)

NewNetworkNamespace implements NetlinkNamespace.

func (*SystemMock) OpenFile

func (mock *SystemMock) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)

OpenFile implements OperatingSystem.

func (*SystemMock) Remove

func (mock *SystemMock) Remove(name string) error

Remove implements OperatingSystem.

func (*SystemMock) SetNamespace

func (mock *SystemMock) SetNamespace(ns netns.NsHandle) error

SetNamespace implements NetNsNamespace.

func (*SystemMock) Unmount

func (mock *SystemMock) Unmount(target string, flags int) error

Unmount implements Syscall.

func (*SystemMock) When

func (mock *SystemMock) When(name string) *WhenStResp

When defines name of the related method. It creates a new instance of WhenStResp with provided method name and stores it to the mock.

type WhenStResp

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

WhenStResp is helper struct with single method call and desired response items

func (*WhenStResp) ThenReturn

func (when *WhenStResp) ThenReturn(item ...interface{})

ThenReturn receives array of items, which are desired to be returned in mocked method defined in "When". The full logic is: - When('someMethod').ThenReturn('values')

Provided values should match return types of method. If method returns multiple values and only one is provided, mock tries to parse the value and returns it, while others will be nil or empty.

If method is called several times, all cases must be defined separately, even if the return value is the same: - When('method1').ThenReturn('val1') - When('method1').ThenReturn('val1')

All mocked methods are evaluated in same order they were assigned.

Jump to

Keyboard shortcuts

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