linuxmock

package
v1.9.0-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IfNetlinkHandlerMock

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

IfNetlinkHandlerMock allows to mock netlink-related methods

func NewIfNetlinkHandlerMock

func NewIfNetlinkHandlerMock() *IfNetlinkHandlerMock

NewIfNetlinkHandlerMock creates new instance of the mock and initializes response list

func (*IfNetlinkHandlerMock) AddInterfaceIP

func (mock *IfNetlinkHandlerMock) AddInterfaceIP(ifName string, addr *net.IPNet) error

AddInterfaceIP implements NetlinkAPI.

func (*IfNetlinkHandlerMock) AddVethInterfacePair

func (mock *IfNetlinkHandlerMock) AddVethInterfacePair(ifName, peerIfName string) error

AddVethInterfacePair implements NetlinkAPI.

func (*IfNetlinkHandlerMock) DelInterfaceIP

func (mock *IfNetlinkHandlerMock) DelInterfaceIP(ifName string, addr *net.IPNet) error

DelInterfaceIP implements NetlinkAPI.

func (*IfNetlinkHandlerMock) DelVethInterfacePair

func (mock *IfNetlinkHandlerMock) DelVethInterfacePair(ifName, peerIfName string) error

DelVethInterfacePair implements NetlinkAPI.

func (*IfNetlinkHandlerMock) DumpInterfaceStatistics

func (mock *IfNetlinkHandlerMock) DumpInterfaceStatistics() ([]*linuxcalls.LinuxInterfaceStatistics, error)

DumpInterfaceStatistics does not return a value

func (*IfNetlinkHandlerMock) DumpInterfaces

func (mock *IfNetlinkHandlerMock) DumpInterfaces() ([]*linuxcalls.LinuxInterfaceDetails, error)

DumpInterfaces does not return a value

func (*IfNetlinkHandlerMock) GetAddressList

func (mock *IfNetlinkHandlerMock) GetAddressList(ifName string) ([]netlink.Addr, error)

GetAddressList implements NetlinkAPI.

func (*IfNetlinkHandlerMock) GetCallsFor

func (mock *IfNetlinkHandlerMock) GetCallsFor(name string) (numCalls int, params map[int][]interface{})

GetCallsFor returns number of calls for specific method including parameters used for every call

func (*IfNetlinkHandlerMock) GetInterfaceByName

func (mock *IfNetlinkHandlerMock) GetInterfaceByName(ifName string) (*net.Interface, error)

GetInterfaceByName implements NetlinkAPI.

func (*IfNetlinkHandlerMock) GetInterfaceType

func (mock *IfNetlinkHandlerMock) GetInterfaceType(ifName string) (string, error)

GetInterfaceType implements NetlinkAPI.

func (*IfNetlinkHandlerMock) GetLinkByName

func (mock *IfNetlinkHandlerMock) GetLinkByName(ifName string) (netlink.Link, error)

GetLinkByName implements NetlinkAPI.

func (mock *IfNetlinkHandlerMock) GetLinkList() ([]netlink.Link, error)

GetLinkList implements NetlinkAPI.

func (*IfNetlinkHandlerMock) GetVethPeerName

func (mock *IfNetlinkHandlerMock) GetVethPeerName(ifName string) (string, error)

GetVethPeerName implements NetlinkAPI.

func (*IfNetlinkHandlerMock) InterfaceExists

func (mock *IfNetlinkHandlerMock) InterfaceExists(ifName string) (bool, error)

InterfaceExists implements NetlinkAPI.

func (*IfNetlinkHandlerMock) RenameInterface

func (mock *IfNetlinkHandlerMock) RenameInterface(ifName string, newName string) error

RenameInterface implements NetlinkAPI.

func (*IfNetlinkHandlerMock) SetInterfaceDown

func (mock *IfNetlinkHandlerMock) SetInterfaceDown(ifName string) error

SetInterfaceDown implements NetlinkAPI.

func (*IfNetlinkHandlerMock) SetInterfaceMTU

func (mock *IfNetlinkHandlerMock) SetInterfaceMTU(ifName string, mtu int) error

SetInterfaceMTU implements NetlinkAPI.

func (*IfNetlinkHandlerMock) SetInterfaceMac

func (mock *IfNetlinkHandlerMock) SetInterfaceMac(ifName string, macAddress string) error

SetInterfaceMac implements NetlinkAPI.

func (*IfNetlinkHandlerMock) SetInterfaceUp

func (mock *IfNetlinkHandlerMock) SetInterfaceUp(ifName string) error

SetInterfaceUp implements NetlinkAPI.

func (*IfNetlinkHandlerMock) When

func (mock *IfNetlinkHandlerMock) When(name string) *WhenIfResp

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

type L3NetlinkHandlerMock

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

L3NetlinkHandlerMock allows to mock netlink-related methods

func NewL3NetlinkHandlerMock

func NewL3NetlinkHandlerMock() *L3NetlinkHandlerMock

NewL3NetlinkHandlerMock creates new instance of the mock and initializes response list

func (*L3NetlinkHandlerMock) AddArpEntry

func (mock *L3NetlinkHandlerMock) AddArpEntry(name string, arpEntry *netlink.Neigh) error

AddArpEntry implements NetlinkAPI.

func (*L3NetlinkHandlerMock) AddStaticRoute

func (mock *L3NetlinkHandlerMock) AddStaticRoute(name string, route *netlink.Route) error

AddStaticRoute implements NetlinkAPI.

func (*L3NetlinkHandlerMock) DelArpEntry

func (mock *L3NetlinkHandlerMock) DelArpEntry(name string, arpEntry *netlink.Neigh) error

DelArpEntry implements NetlinkAPI.

func (*L3NetlinkHandlerMock) DelStaticRoute

func (mock *L3NetlinkHandlerMock) DelStaticRoute(name string, route *netlink.Route) error

DelStaticRoute implements NetlinkAPI.

func (*L3NetlinkHandlerMock) DumpArpEntries

func (mock *L3NetlinkHandlerMock) DumpArpEntries() ([]*linuxcalls.LinuxArpDetails, error)

DumpArpEntries does not return a value

func (*L3NetlinkHandlerMock) DumpRoutes

func (mock *L3NetlinkHandlerMock) DumpRoutes() ([]*linuxcalls.LinuxRouteDetails, error)

DumpRoutes does not return a value

func (*L3NetlinkHandlerMock) GetArpEntries

func (mock *L3NetlinkHandlerMock) GetArpEntries(interfaceIdx int, family int) ([]netlink.Neigh, error)

GetArpEntries implements NetlinkAPI.

func (*L3NetlinkHandlerMock) GetStaticRoutes

func (mock *L3NetlinkHandlerMock) GetStaticRoutes(link netlink.Link, family int) ([]netlink.Route, error)

GetStaticRoutes implements NetlinkAPI.

func (*L3NetlinkHandlerMock) ReplaceStaticRoute

func (mock *L3NetlinkHandlerMock) ReplaceStaticRoute(name string, route *netlink.Route) error

ReplaceStaticRoute implements NetlinkAPI.

func (*L3NetlinkHandlerMock) SetArpEntry

func (mock *L3NetlinkHandlerMock) SetArpEntry(name string, arpEntry *netlink.Neigh) error

SetArpEntry implements NetlinkAPI.

func (*L3NetlinkHandlerMock) When

func (mock *L3NetlinkHandlerMock) When(name string) *WhenL3Resp

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

type NamespacePluginMock

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

NamespacePluginMock allows to mock namespace plugin methods to manage namespaces and microservices

func NewNamespacePluginMock

func NewNamespacePluginMock() *NamespacePluginMock

NewNamespacePluginMock creates new instance of the mock and initializes response list

func (*NamespacePluginMock) ArpNsToGeneric

ArpNsToGeneric implements NsConvertor.

func (*NamespacePluginMock) ConvertMicroserviceNsToPidNs

func (mock *NamespacePluginMock) ConvertMicroserviceNsToPidNs(msLabel string) (pidNs *nsplugin.Namespace)

ConvertMicroserviceNsToPidNs implements NsManagement

func (*NamespacePluginMock) GenericToArpNs

GenericToArpNs implements NsConvertor.

func (*NamespacePluginMock) GetConfigNamespace

GetConfigNamespace implements NsManagement.

func (*NamespacePluginMock) GetOrCreateNamespace

func (mock *NamespacePluginMock) GetOrCreateNamespace(ns *nsplugin.Namespace) (netns.NsHandle, error)

GetOrCreateNamespace implements NsManagement.

func (*NamespacePluginMock) HandleMicroservices

func (mock *NamespacePluginMock) HandleMicroservices(ctx *nsplugin.MicroserviceCtx)

HandleMicroservices implements Microservices.

func (*NamespacePluginMock) IfNsToGeneric

IfNsToGeneric implements NsConvertor.

func (*NamespacePluginMock) IfaceNsToString

IfaceNsToString implements NsConvertor.

func (*NamespacePluginMock) IsNamespaceAvailable

IsNamespaceAvailable implements NsManagement.

func (*NamespacePluginMock) RouteNsToGeneric

RouteNsToGeneric implements NsConvertor.

func (*NamespacePluginMock) SwitchNamespace

func (mock *NamespacePluginMock) SwitchNamespace(ns *nsplugin.Namespace, ctx *nsplugin.NamespaceMgmtCtx) (func(), error)

SwitchNamespace implements NsManagement.

func (*NamespacePluginMock) SwitchToNamespace

func (mock *NamespacePluginMock) SwitchToNamespace(nsMgmtCtx *nsplugin.NamespaceMgmtCtx, ns *interfaces.LinuxInterfaces_Interface_Namespace) (func(), error)

SwitchToNamespace implements NsManagement.

func (*NamespacePluginMock) When

func (mock *NamespacePluginMock) When(methodName string) *WhenNsResp

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

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 WhenIfResp

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

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

func (*WhenIfResp) ThenReturn

func (when *WhenIfResp) 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.

type WhenL3Resp

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

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

func (*WhenL3Resp) ThenReturn

func (when *WhenL3Resp) 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.

type WhenNsResp

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

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

func (*WhenNsResp) ThenReturn

func (when *WhenNsResp) 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.

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