Documentation
¶
Overview ¶
Package testutil provides testing utilities for Wormhole.
This package contains mock implementations, test helpers, and fixtures used across the test suite.
Index ¶
- func Eventually(t *testing.T, timeout time.Duration, interval time.Duration, ...)
- func GetFreePort(t *testing.T) int
- func NewMockConnPair() (*MockConn, *MockConn)
- func RequireEqual[T comparable](t *testing.T, expected, actual T)
- func RequireError(t *testing.T, err error)
- func RequireNoError(t *testing.T, err error)
- func RequireTrue(t *testing.T, condition bool, msg string)
- func RunInGoroutine(t *testing.T, timeout time.Duration, fn func())
- func WaitFor(t *testing.T, timeout time.Duration, condition func() bool)
- func WithTimeout(t *testing.T, d time.Duration) context.Context
- type MockAddr
- type MockConn
- func (c *MockConn) Close() error
- func (c *MockConn) IsClosed() bool
- func (c *MockConn) LocalAddr() net.Addr
- func (c *MockConn) Read(b []byte) (n int, err error)
- func (c *MockConn) RemoteAddr() net.Addr
- func (c *MockConn) SetDeadline(_ time.Time) error
- func (c *MockConn) SetReadDeadline(_ time.Time) error
- func (c *MockConn) SetWriteDeadline(_ time.Time) error
- func (c *MockConn) Write(b []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Eventually ¶
Eventually asserts that the condition becomes true within the timeout.
func NewMockConnPair ¶
NewMockConnPair creates a pair of connected MockConn instances. Data written to one connection can be read from the other.
func RequireEqual ¶
func RequireEqual[T comparable](t *testing.T, expected, actual T)
RequireEqual fails the test if expected != actual.
func RequireError ¶
RequireError fails the test if err is nil.
func RequireNoError ¶
RequireNoError fails the test if err is not nil.
func RequireTrue ¶
RequireTrue fails the test if condition is false.
func RunInGoroutine ¶
RunInGoroutine runs the function in a goroutine and waits for completion. It fails the test if the function doesn't complete within the timeout.
Types ¶
type MockConn ¶
type MockConn struct {
// contains filtered or unexported fields
}
MockConn implements net.Conn for testing purposes. It uses two connected pipes for bidirectional communication.
func (*MockConn) RemoteAddr ¶
RemoteAddr returns the remote network address.
func (*MockConn) SetDeadline ¶
SetDeadline sets the read and write deadlines.
func (*MockConn) SetReadDeadline ¶
SetReadDeadline sets the deadline for future Read calls.
func (*MockConn) SetWriteDeadline ¶
SetWriteDeadline sets the deadline for future Write calls.