Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMockESClient ¶
func NewMockESClient(responses []MockResponse) (*elasticsearch.Client, error)
NewMockESClient creates an Elasticsearch client with mocked HTTP transport. This allows you to test with the real elasticsearch.Client API while controlling responses.
func NewMockESClientWithError ¶
NewMockESClientWithError creates an Elasticsearch client that returns an error on requests. This is useful for testing error handling.
func NewMockESClientWithSingleResponse ¶
func NewMockESClientWithSingleResponse(responseBody string, statusCode int) (*elasticsearch.Client, error)
NewMockESClientWithSingleResponse creates an Elasticsearch client with a single mock response. This is a convenience function for simple test cases.
Types ¶
type MockResponse ¶
MockResponse represents a single mock HTTP response.
type MockTransport ¶
type MockTransport struct {
// contains filtered or unexported fields
}
MockTransport provides HTTP transport mock for testing Elasticsearch client. This allows testing with the real elasticsearch.Client API without interface constraints.
func NewMockTransport ¶
func NewMockTransport(responses []MockResponse) *MockTransport
NewMockTransport creates a new MockTransport with the given responses. Responses are returned in order. If more requests are made than responses provided, the last response is repeated.