Documentation
¶
Index ¶
- type MockTransport
- func (m *MockTransport) ClearRequests()
- func (m *MockTransport) FindRequest(method, pathContains string) *RequestRecord
- func (m *MockTransport) GetRequestCount() int
- func (m *MockTransport) GetRequests() []*RequestRecord
- func (m *MockTransport) RoundTrip(req *http.Request) (*http.Response, error)
- func (m *MockTransport) SetDefaultResponse(response *http.Response)
- func (m *MockTransport) SetResponse(method, path string, response *http.Response)
- func (m *MockTransport) SetResponseWithBody(method, path string, statusCode int, body interface{})
- type MockWebSocketConn
- func (m *MockWebSocketConn) ClearWrittenMessages()
- func (m *MockWebSocketConn) Close() error
- func (m *MockWebSocketConn) GetWrittenMessages() [][]byte
- func (m *MockWebSocketConn) IsClosed() bool
- func (m *MockWebSocketConn) QueueJSONMessage(v interface{}) error
- func (m *MockWebSocketConn) QueueMessage(message []byte)
- func (m *MockWebSocketConn) ReadMessage() (int, []byte, error)
- func (m *MockWebSocketConn) SendError(err error)
- func (m *MockWebSocketConn) SendMessage(message []byte)
- func (m *MockWebSocketConn) SetCloseError(err error)
- func (m *MockWebSocketConn) SetReadError(err error)
- func (m *MockWebSocketConn) SetWriteError(err error)
- func (m *MockWebSocketConn) WriteMessage(messageType int, data []byte) error
- type MockWebSocketDialer
- func (m *MockWebSocketDialer) DialContext(ctx context.Context, urlStr string, requestHeader map[string][]string) (*MockWebSocketConn, error)
- func (m *MockWebSocketDialer) GetConnection(urlStr string) *MockWebSocketConn
- func (m *MockWebSocketDialer) SetConnection(urlStr string, conn *MockWebSocketConn)
- func (m *MockWebSocketDialer) SetDefaultConnection(conn *MockWebSocketConn)
- type RequestRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockTransport ¶
type MockTransport struct {
// contains filtered or unexported fields
}
MockTransport is a mock HTTP RoundTripper that records requests and returns fixture-based responses.
func NewMockTransport ¶
func NewMockTransport(fixtureDir string) *MockTransport
NewMockTransport creates a new MockTransport.
func (*MockTransport) ClearRequests ¶
func (m *MockTransport) ClearRequests()
ClearRequests clears the request history.
func (*MockTransport) FindRequest ¶
func (m *MockTransport) FindRequest(method, pathContains string) *RequestRecord
FindRequest finds a request matching the criteria.
func (*MockTransport) GetRequestCount ¶
func (m *MockTransport) GetRequestCount() int
GetRequestCount returns the number of recorded requests.
func (*MockTransport) GetRequests ¶
func (m *MockTransport) GetRequests() []*RequestRecord
GetRequests returns all recorded requests.
func (*MockTransport) SetDefaultResponse ¶
func (m *MockTransport) SetDefaultResponse(response *http.Response)
SetDefaultResponse sets a default response for unmatched requests.
func (*MockTransport) SetResponse ¶
func (m *MockTransport) SetResponse(method, path string, response *http.Response)
SetResponse sets a specific response for a request pattern.
func (*MockTransport) SetResponseWithBody ¶
func (m *MockTransport) SetResponseWithBody(method, path string, statusCode int, body interface{})
SetResponseWithBody sets a response with JSON body.
type MockWebSocketConn ¶
type MockWebSocketConn struct {
// contains filtered or unexported fields
}
MockWebSocketConn is a mock WebSocket connection for testing.
func NewMockWebSocketConn ¶
func NewMockWebSocketConn() *MockWebSocketConn
NewMockWebSocketConn creates a new mock WebSocket connection.
func (*MockWebSocketConn) ClearWrittenMessages ¶
func (m *MockWebSocketConn) ClearWrittenMessages()
ClearWrittenMessages clears the written messages history.
func (*MockWebSocketConn) Close ¶
func (m *MockWebSocketConn) Close() error
Close closes the connection.
func (*MockWebSocketConn) GetWrittenMessages ¶
func (m *MockWebSocketConn) GetWrittenMessages() [][]byte
GetWrittenMessages returns all messages written to the connection.
func (*MockWebSocketConn) IsClosed ¶
func (m *MockWebSocketConn) IsClosed() bool
IsClosed returns whether the connection is closed.
func (*MockWebSocketConn) QueueJSONMessage ¶
func (m *MockWebSocketConn) QueueJSONMessage(v interface{}) error
QueueJSONMessage queues a JSON message to be read.
func (*MockWebSocketConn) QueueMessage ¶
func (m *MockWebSocketConn) QueueMessage(message []byte)
QueueMessage queues a message to be read.
func (*MockWebSocketConn) ReadMessage ¶
func (m *MockWebSocketConn) ReadMessage() (int, []byte, error)
ReadMessage reads a message from the connection.
func (*MockWebSocketConn) SendError ¶
func (m *MockWebSocketConn) SendError(err error)
SendError sends an error through the error channel, preserving an earlier error when full.
func (*MockWebSocketConn) SendMessage ¶
func (m *MockWebSocketConn) SendMessage(message []byte)
SendMessage sends a message through the message channel.
func (*MockWebSocketConn) SetCloseError ¶
func (m *MockWebSocketConn) SetCloseError(err error)
SetCloseError sets an error to return on Close.
func (*MockWebSocketConn) SetReadError ¶
func (m *MockWebSocketConn) SetReadError(err error)
SetReadError sets an error to return on ReadMessage.
func (*MockWebSocketConn) SetWriteError ¶
func (m *MockWebSocketConn) SetWriteError(err error)
SetWriteError sets an error to return on WriteMessage.
func (*MockWebSocketConn) WriteMessage ¶
func (m *MockWebSocketConn) WriteMessage(messageType int, data []byte) error
WriteMessage writes a message to the connection.
type MockWebSocketDialer ¶
type MockWebSocketDialer struct {
// contains filtered or unexported fields
}
MockWebSocketDialer is a mock WebSocket dialer for testing.
func NewMockWebSocketDialer ¶
func NewMockWebSocketDialer() *MockWebSocketDialer
NewMockWebSocketDialer creates a new mock WebSocket dialer.
func (*MockWebSocketDialer) DialContext ¶
func (m *MockWebSocketDialer) DialContext( ctx context.Context, urlStr string, requestHeader map[string][]string, ) (*MockWebSocketConn, error)
DialContext mocks the WebSocket dial operation.
func (*MockWebSocketDialer) GetConnection ¶
func (m *MockWebSocketDialer) GetConnection(urlStr string) *MockWebSocketConn
GetConnection returns the connection for a URL.
func (*MockWebSocketDialer) SetConnection ¶
func (m *MockWebSocketDialer) SetConnection(urlStr string, conn *MockWebSocketConn)
SetConnection sets a connection for a specific URL.
func (*MockWebSocketDialer) SetDefaultConnection ¶
func (m *MockWebSocketDialer) SetDefaultConnection(conn *MockWebSocketConn)
SetDefaultConnection sets a default connection to use.