Documentation ¶
Overview ¶
Package test contains the testing types for wire/net.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conn ¶ added in v0.4.1
type Conn struct {
// contains filtered or unexported fields
}
Conn is a testing connection.
type ConnHub ¶
ConnHub is a factory for creating and connecting test dialers and listeners.
func (*ConnHub) NewNetDialer ¶
NewNetDialer creates a new test dialer. Registers the new dialer in the hub. Panics if the hub is closed.
type Dialer ¶
Dialer is a test dialer that can dial connections to Listeners via a ConnHub.
type Listener ¶
Listener is a mocked listener that can be used to control and examine a listener. Accept() calls can be manually controlled via Put(). Accepted() tracks the number of accepted connections. IsClosed() can be used to detect whether a Listener is still open.
func (*Listener) Accept ¶
Accept returns the next connection that is enqueued via Put(). This function blocks until either Put() is called or until the listener is closed.
func (*Listener) Close ¶
Close closes the test listener. This aborts any ongoing Accept() call and all future Accept() calls will fail. If the listener is already closed, returns an error.
func (*Listener) NumAccepted ¶
NumAccepted returns the number of connections that have been accepted by the listener. Note that this number is updated before Accept() returns, but not necessarily before Put() returns.
func (*Listener) Put ¶
Put enqueues one connection to be returned by Accept(). If the listener is already closed, does nothing. This function blocks until either Accept() is called or until the listener is closed. Returns whether the connection has been retrieved by Accept().
Note that if Put() is called in parallel, there is no ordering guarantee for the accepted connections.