Documentation
¶
Index ¶
- func CalledWith(mock *SocketBridgeManagerMock, method, containerID string) bool
- func NewTestManager(t *testing.T) (*socketbridge.Manager, string)
- func WriteTestMessage(buf *bytes.Buffer, msg socketbridge.Message)
- type FlushWriteCloser
- type NopWriteCloser
- type SocketBridgeManagerMock
- func (mock *SocketBridgeManagerMock) EnsureBridge(containerID string, gpgEnabled bool) error
- func (mock *SocketBridgeManagerMock) EnsureBridgeCalls() []struct{ ... }
- func (mock *SocketBridgeManagerMock) IsRunning(containerID string) bool
- func (mock *SocketBridgeManagerMock) IsRunningCalls() []struct{ ... }
- func (mock *SocketBridgeManagerMock) StopAll() error
- func (mock *SocketBridgeManagerMock) StopAllCalls() []struct{}
- func (mock *SocketBridgeManagerMock) StopBridge(containerID string) error
- func (mock *SocketBridgeManagerMock) StopBridgeCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalledWith ¶
func CalledWith(mock *SocketBridgeManagerMock, method, containerID string) bool
CalledWith returns true if the given method was called with the given containerID. Convenience wrapper over moq's typed call slices.
func NewTestManager ¶
func NewTestManager(t *testing.T) (*socketbridge.Manager, string)
NewTestManager creates a socketbridge.Manager backed by a real, file-backed config isolated to a temp directory. Returns the manager and its state dir so tests can create PID files where BridgePIDFilePath will find them. Uses NewIsolatedTestConfig under the hood so path helpers (BridgePIDFilePath, BridgesSubdir, LogsSubdir) work against real directories instead of panicking on nil mock funcs.
func WriteTestMessage ¶
func WriteTestMessage(buf *bytes.Buffer, msg socketbridge.Message)
WriteTestMessage writes a socketbridge protocol message to buf in the wire format: [4-byte length][1-byte type][4-byte streamID][payload].
Types ¶
type FlushWriteCloser ¶
FlushWriteCloser wraps an io.Writer with a no-op Close method, useful for testing sendMessage against a *bytes.Buffer.
func (*FlushWriteCloser) Close ¶
func (f *FlushWriteCloser) Close() error
Close implements io.WriteCloser.
type NopWriteCloser ¶
type NopWriteCloser struct{}
NopWriteCloser is a no-op io.WriteCloser for testing. Writes are accepted and discarded; Close is a no-op.
type SocketBridgeManagerMock ¶
type SocketBridgeManagerMock struct {
// EnsureBridgeFunc mocks the EnsureBridge method.
EnsureBridgeFunc func(containerID string, gpgEnabled bool) error
// IsRunningFunc mocks the IsRunning method.
IsRunningFunc func(containerID string) bool
// StopAllFunc mocks the StopAll method.
StopAllFunc func() error
// StopBridgeFunc mocks the StopBridge method.
StopBridgeFunc func(containerID string) error
// contains filtered or unexported fields
}
SocketBridgeManagerMock is a mock implementation of socketbridge.SocketBridgeManager.
func TestSomethingThatUsesSocketBridgeManager(t *testing.T) {
// make and configure a mocked socketbridge.SocketBridgeManager
mockedSocketBridgeManager := &SocketBridgeManagerMock{
EnsureBridgeFunc: func(containerID string, gpgEnabled bool) error {
panic("mock out the EnsureBridge method")
},
IsRunningFunc: func(containerID string) bool {
panic("mock out the IsRunning method")
},
StopAllFunc: func() error {
panic("mock out the StopAll method")
},
StopBridgeFunc: func(containerID string) error {
panic("mock out the StopBridge method")
},
}
// use mockedSocketBridgeManager in code that requires socketbridge.SocketBridgeManager
// and then make assertions.
}
func NewMockManager ¶
func NewMockManager() *SocketBridgeManagerMock
NewMockManager creates a SocketBridgeManagerMock with no-op defaults. Unlike bare moq (which panics on nil Func fields), this wires safe defaults so tests only need to override the methods they care about.
func (*SocketBridgeManagerMock) EnsureBridge ¶
func (mock *SocketBridgeManagerMock) EnsureBridge(containerID string, gpgEnabled bool) error
EnsureBridge calls EnsureBridgeFunc.
func (*SocketBridgeManagerMock) EnsureBridgeCalls ¶
func (mock *SocketBridgeManagerMock) EnsureBridgeCalls() []struct { ContainerID string GpgEnabled bool }
EnsureBridgeCalls gets all the calls that were made to EnsureBridge. Check the length with:
len(mockedSocketBridgeManager.EnsureBridgeCalls())
func (*SocketBridgeManagerMock) IsRunning ¶
func (mock *SocketBridgeManagerMock) IsRunning(containerID string) bool
IsRunning calls IsRunningFunc.
func (*SocketBridgeManagerMock) IsRunningCalls ¶
func (mock *SocketBridgeManagerMock) IsRunningCalls() []struct { ContainerID string }
IsRunningCalls gets all the calls that were made to IsRunning. Check the length with:
len(mockedSocketBridgeManager.IsRunningCalls())
func (*SocketBridgeManagerMock) StopAll ¶
func (mock *SocketBridgeManagerMock) StopAll() error
StopAll calls StopAllFunc.
func (*SocketBridgeManagerMock) StopAllCalls ¶
func (mock *SocketBridgeManagerMock) StopAllCalls() []struct { }
StopAllCalls gets all the calls that were made to StopAll. Check the length with:
len(mockedSocketBridgeManager.StopAllCalls())
func (*SocketBridgeManagerMock) StopBridge ¶
func (mock *SocketBridgeManagerMock) StopBridge(containerID string) error
StopBridge calls StopBridgeFunc.
func (*SocketBridgeManagerMock) StopBridgeCalls ¶
func (mock *SocketBridgeManagerMock) StopBridgeCalls() []struct { ContainerID string }
StopBridgeCalls gets all the calls that were made to StopBridge. Check the length with:
len(mockedSocketBridgeManager.StopBridgeCalls())