Documentation
¶
Index ¶
- Variables
- type MockConn
- func (c *MockConn) Close() error
- func (c *MockConn) CloseCalls() int
- func (c *MockConn) ClosedAt() time.Time
- func (c *MockConn) LocalAddr() net.Addr
- func (c *MockConn) Read(b []byte) (int, error)
- func (c *MockConn) ReadCalls() int
- func (c *MockConn) RemoteAddr() net.Addr
- func (c *MockConn) SetDeadline(t time.Time) error
- func (c *MockConn) SetReadDeadline(t time.Time) error
- func (c *MockConn) SetWriteDeadline(t time.Time) error
- func (c *MockConn) Write(b []byte) (int, error)
- func (c *MockConn) WriteCalls() int
- type MockListener
- type MockSSHClient
- type SyncBuffer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTemporaryTrue is an error that implements a Temporary method // that always returns true. ErrTemporaryTrue tempErr = true // ErrTemporaryFalse is an error that implements a Temporary method // that always returns false. ErrTemporaryFalse tempErr = false )
Functions ¶
This section is empty.
Types ¶
type MockConn ¶
type MockConn struct { // Function to call when Read is called. ReadFunc func(i int, b []byte) (int, error) // Function to call when Write is called. WriteFunc func(i int, b []byte) (int, error) // Error to return when Close is called. CloseErr error // If set, the channel is closed when Close is called. CloseChan chan struct{} // Local address to return when LocalAddr is called. LocalAddress net.Addr // Remote address to return when RemoteAddr is called. RemoteAddress net.Addr // contains filtered or unexported fields }
MockConn implements a net.Conn that can be used for testing. Deadline methods are no-ops.
func (*MockConn) CloseCalls ¶
CloseCalls returns the number of times Close was called.
func (*MockConn) ClosedAt ¶ added in v0.0.2
ClosedAt returns the timestamp at which the connection was closed.
func (*MockConn) RemoteAddr ¶
RemoteAddr returns the remote address of the connection.
func (*MockConn) SetDeadline ¶
SetDeadline is a no-op for MockConn.
func (*MockConn) SetReadDeadline ¶
SetReadDeadline is a no-op for MockConn.
func (*MockConn) SetWriteDeadline ¶
SetWriteDeadline is a no-op for MockConn.
func (*MockConn) WriteCalls ¶
WriteCalls returns the number of times Write was called.
type MockListener ¶
type MockListener struct { // AcceptFunc is the function called whenever Accept is called. // The i parameter indicates the 0-based index of the call. AcceptFunc func(i int) (net.Conn, error) // Error to return when Close is called on the Listener. CloseErr error // If set, this channel is closed when Close is called. CloseChan chan struct{} // Address to return when Addr is called on the Listener. Address net.Addr // contains filtered or unexported fields }
MockListener is a net.Listener that calls AcceptFunc to return the connection and error.
func (*MockListener) Accept ¶
func (l *MockListener) Accept() (net.Conn, error)
Accept accepts a connection.
func (*MockListener) AcceptCalls ¶
func (l *MockListener) AcceptCalls() int
AcceptCalls returns the number of times Accept was called.
func (*MockListener) Addr ¶
func (l *MockListener) Addr() net.Addr
Addr returns the address the Listener listens on.
func (*MockListener) CloseCalls ¶
func (l *MockListener) CloseCalls() int
CloseCalls returns the number of times Close was called.
type MockSSHClient ¶
type MockSSHClient struct { // Function to call when Dial is called. DialFunc func(i int, network, address string) (net.Conn, error) // Error to return when Close is called. CloseErr error // If set, the channel is closed when Close is called. CloseChan chan struct{} // contains filtered or unexported fields }
MockSSHClient implements an SSH client (more specifically, a dialCloser interface as defined in the server package) that can be used for tests.
func (*MockSSHClient) CloseCalls ¶
func (c *MockSSHClient) CloseCalls() int
CloseCalls returns the number of times Close was called.
func (*MockSSHClient) Dial ¶
func (c *MockSSHClient) Dial(n, addr string) (net.Conn, error)
Dial attempts a connection to the specified address.
func (*MockSSHClient) DialCalls ¶
func (c *MockSSHClient) DialCalls() int
DialCalls returns the number of times Dial was called.
type SyncBuffer ¶
type SyncBuffer struct {
// contains filtered or unexported fields
}
SyncBuffer is a bytes.Buffer protected by a mutex.
func (*SyncBuffer) Bytes ¶
func (b *SyncBuffer) Bytes() []byte
Bytes returns the buffer's data as raw bytes.
func (*SyncBuffer) Read ¶
func (b *SyncBuffer) Read(p []byte) (int, error)
Read implements io.Reader for SyncBuffer.
func (*SyncBuffer) String ¶
func (b *SyncBuffer) String() string
String returns the buffer's data as a string.