Documentation
¶
Index ¶
- func AssertContains(t *testing.T, container, item string, msgAndArgs ...interface{})
- func AssertEqual(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{})
- func AssertError(t *testing.T, err error, msgAndArgs ...interface{})
- func AssertFalse(t *testing.T, value bool, msgAndArgs ...interface{})
- func AssertNoError(t *testing.T, err error, msgAndArgs ...interface{})
- func AssertNotContains(t *testing.T, container, item string, msgAndArgs ...interface{})
- func AssertNotEqual(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{})
- func AssertTrue(t *testing.T, value bool, msgAndArgs ...interface{})
- func ContainsString(s, substr string) bool
- func CreateJSONResponse(statusCode int, data interface{}) *http.Response
- func CreateMockResponse(statusCode int, body string, headers map[string]string) *http.Response
- func CreateTempFile(t *testing.T, dir, name, content string) string
- func Eventually(t *testing.T, condition func() bool, timeout time.Duration, ...)
- func MockConfig() *config.Config
- func MockContext(timeout time.Duration) (context.Context, context.CancelFunc)
- func MockContextWithValue(key, value interface{}) context.Context
- func MockProvider(name string) config.Provider
- func WithTimeout(t *testing.T, timeout time.Duration, fn func())
- type CaptureLog
- type MockHTTPClient
- func (m *MockHTTPClient) Do(req *http.Request) (*http.Response, error)
- func (m *MockHTTPClient) GetLastRequest() *http.Request
- func (m *MockHTTPClient) GetRequests() []*http.Request
- func (m *MockHTTPClient) Reset()
- func (m *MockHTTPClient) SetError(err error)
- func (m *MockHTTPClient) SetResponse(url string, response *http.Response)
- func (m *MockHTTPClient) SetResponseFunc(fn func(*http.Request) (*http.Response, error))
- type MockServer
- type TestConfig
- type TestLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertContains ¶
AssertContains fails the test if container does not contain item
func AssertEqual ¶
AssertEqual fails the test if expected != actual
func AssertError ¶
AssertError fails the test if err is nil
func AssertFalse ¶
AssertFalse fails the test if value is not false
func AssertNoError ¶
AssertNoError fails the test if err is not nil
func AssertNotContains ¶
AssertNotContains fails the test if container contains item
func AssertNotEqual ¶
AssertNotEqual fails the test if expected == actual
func AssertTrue ¶
AssertTrue fails the test if value is not true
func ContainsString ¶
ContainsString checks if a string contains a substring
func CreateJSONResponse ¶
CreateJSONResponse creates a mock HTTP response with JSON body
func CreateMockResponse ¶
CreateMockResponse creates a mock HTTP response
func CreateTempFile ¶
CreateTempFile creates a temporary file with the given content
func Eventually ¶
func Eventually(t *testing.T, condition func() bool, timeout time.Duration, interval time.Duration, msgAndArgs ...interface{})
Eventually runs the given function repeatedly until it returns true or times out
func MockContext ¶
MockContext creates a mock context with timeout
func MockContextWithValue ¶
MockContextWithValue creates a mock context with a value
func MockProvider ¶
MockProvider creates a mock provider configuration
Types ¶
type CaptureLog ¶
type CaptureLog struct {
// contains filtered or unexported fields
}
CaptureLog captures log output for testing
func (*CaptureLog) Contains ¶
func (c *CaptureLog) Contains(substr string) bool
Contains checks if any log entry contains the substring
func (*CaptureLog) GetEntries ¶
func (c *CaptureLog) GetEntries() []string
GetEntries returns all captured log entries
func (*CaptureLog) GetLastEntry ¶
func (c *CaptureLog) GetLastEntry() string
GetLastEntry returns the last captured log entry
type MockHTTPClient ¶
type MockHTTPClient struct {
// contains filtered or unexported fields
}
MockHTTPClient is a mock implementation of http.Client
func NewMockHTTPClient ¶
func NewMockHTTPClient() *MockHTTPClient
NewMockHTTPClient creates a new mock HTTP client
func (*MockHTTPClient) GetLastRequest ¶
func (m *MockHTTPClient) GetLastRequest() *http.Request
GetLastRequest returns the last captured request
func (*MockHTTPClient) GetRequests ¶
func (m *MockHTTPClient) GetRequests() []*http.Request
GetRequests returns all captured requests
func (*MockHTTPClient) Reset ¶
func (m *MockHTTPClient) Reset()
Reset clears all captured requests and responses
func (*MockHTTPClient) SetError ¶
func (m *MockHTTPClient) SetError(err error)
SetError sets an error to return
func (*MockHTTPClient) SetResponse ¶
func (m *MockHTTPClient) SetResponse(url string, response *http.Response)
SetResponse sets a response for a specific URL
func (*MockHTTPClient) SetResponseFunc ¶
SetResponseFunc sets a function to generate responses
type MockServer ¶
MockServer wraps httptest.Server with additional utilities
func NewMockTLSServer ¶
func NewMockTLSServer() *MockServer
NewMockTLSServer creates a new mock HTTPS server
func (*MockServer) GetRequests ¶
func (ms *MockServer) GetRequests() []*http.Request
GetRequests returns all captured requests
func (*MockServer) SetDefaultResponse ¶
func (ms *MockServer) SetDefaultResponse(status int, body interface{})
SetDefaultResponse sets the default response
func (*MockServer) SetResponseFunc ¶
func (ms *MockServer) SetResponseFunc(fn func(*http.Request) (int, interface{}))
SetResponseFunc sets a function to generate responses
type TestConfig ¶
type TestConfig struct { TempDir string CleanupFunc func() }
TestConfig holds common test configuration
func SetupTest ¶
func SetupTest(t *testing.T) *TestConfig
SetupTest provides common test setup functionality
type TestLogger ¶
type TestLogger struct {
// contains filtered or unexported fields
}
TestLogger provides a logger for testing
func NewTestLogger ¶
func NewTestLogger(t *testing.T) *TestLogger
NewTestLogger creates a new test logger
func (*TestLogger) Debug ¶
func (tl *TestLogger) Debug(msg string, args ...interface{})
Debug logs a debug message
func (*TestLogger) Error ¶
func (tl *TestLogger) Error(msg string, args ...interface{})
Error logs an error message
func (*TestLogger) GetCaptured ¶
func (tl *TestLogger) GetCaptured() *CaptureLog
GetCaptured returns the captured log output
func (*TestLogger) Info ¶
func (tl *TestLogger) Info(msg string, args ...interface{})
Info logs an info message