Documentation
¶
Index ¶
- func CleanupTestData(app *TestApp, endpoint, id string) error
- func CreateTestData(app *TestApp, endpoint string, data map[string]any) (string, error)
- func NewMockDatapoint(value float64, unit types.StandardUnit) types.Datapoint
- func NewMockDeleteAlarmsOutput() *cloudwatch.DeleteAlarmsOutput
- func NewMockDeleteAnomalyDetectorOutput() *cloudwatch.DeleteAnomalyDetectorOutput
- func NewMockDescribeAlarmsOutput(alarms []types.MetricAlarm) *cloudwatch.DescribeAlarmsOutput
- func NewMockDescribeAnomalyDetectorsOutput(detectors []types.AnomalyDetector) *cloudwatch.DescribeAnomalyDetectorsOutput
- func NewMockDimension(name, value string) types.Dimension
- func NewMockGetMetricDataOutput(results []types.MetricDataResult) *cloudwatch.GetMetricDataOutput
- func NewMockGetMetricStatisticsOutput(datapoints []types.Datapoint) *cloudwatch.GetMetricStatisticsOutput
- func NewMockListMetricsOutput(metrics []types.Metric) *cloudwatch.ListMetricsOutput
- func NewMockListTagsForResourceOutput(tags []types.Tag) *cloudwatch.ListTagsForResourceOutput
- func NewMockMetric(name, namespace string) types.Metric
- func NewMockMetricAlarm(name, metricName string, threshold float64) types.MetricAlarm
- func NewMockMetricDatum(name string, value float64, unit types.StandardUnit) types.MetricDatum
- func NewMockPutAnomalyDetectorOutput() *cloudwatch.PutAnomalyDetectorOutput
- func NewMockPutMetricAlarmOutput() *cloudwatch.PutMetricAlarmOutput
- func NewMockPutMetricDataOutput() *cloudwatch.PutMetricDataOutput
- func NewMockTag(key, value string) types.Tag
- func NewMockTagResourceOutput() *cloudwatch.TagResourceOutput
- func NewMockUntagResourceOutput() *cloudwatch.UntagResourceOutput
- func RunScenarios(t *testing.T, app *TestApp, scenarios []TestScenario)
- func TestRateLimiting(t *testing.T, app *TestApp, endpoint string, limit int)
- type AlarmState
- type AuthConfig
- type ComparisonOperator
- type ConnectionState
- type LoadTestConfig
- type LoadTestResult
- type LoadTester
- type MetricUnit
- type MockAPIGatewayConfig
- type MockAPIGatewayError
- type MockAPIGatewayManagementClient
- func (m *MockAPIGatewayManagementClient) DeleteConnection(ctx context.Context, connectionID string) error
- func (m *MockAPIGatewayManagementClient) GetActiveConnections() map[string]*MockConnection
- func (m *MockAPIGatewayManagementClient) GetCallCount(operation string) int
- func (m *MockAPIGatewayManagementClient) GetConnection(ctx context.Context, connectionID string) (*MockConnectionInfo, error)
- func (m *MockAPIGatewayManagementClient) GetConnectionState(connectionID string) *MockConnection
- func (m *MockAPIGatewayManagementClient) GetMessageCount(connectionID string) int
- func (m *MockAPIGatewayManagementClient) GetMessages(connectionID string) [][]byte
- func (m *MockAPIGatewayManagementClient) PostToConnection(ctx context.Context, connectionID string, data []byte) error
- func (m *MockAPIGatewayManagementClient) Reset()
- func (m *MockAPIGatewayManagementClient) SimulateConnectionExpiry()
- func (m *MockAPIGatewayManagementClient) WithConfig(config *MockAPIGatewayConfig) *MockAPIGatewayManagementClient
- func (m *MockAPIGatewayManagementClient) WithConnection(connectionID string, conn *MockConnection) *MockAPIGatewayManagementClient
- func (m *MockAPIGatewayManagementClient) WithError(connectionID string, err error) *MockAPIGatewayManagementClient
- type MockAWSService
- func (m *MockAWSService) Call(operation string, input any) (any, error)
- func (m *MockAWSService) GetCallCount(operation string) int
- func (m *MockAWSService) Reset()
- func (m *MockAWSService) WithError(operation string, err error) *MockAWSService
- func (m *MockAWSService) WithResponse(operation string, response any) *MockAWSService
- type MockAlarmDefinition
- type MockCloudWatchAlarmsClient
- func (m *MockCloudWatchAlarmsClient) DeleteAlarms(ctx context.Context, alarmNames []string) error
- func (m *MockCloudWatchAlarmsClient) DescribeAlarms(ctx context.Context, alarmNames []string) ([]*MockAlarmDefinition, error)
- func (m *MockCloudWatchAlarmsClient) EvaluateAlarms(ctx context.Context) error
- func (m *MockCloudWatchAlarmsClient) GetAlarm(alarmName string) *MockAlarmDefinition
- func (m *MockCloudWatchAlarmsClient) GetAllAlarms() map[string]*MockAlarmDefinition
- func (m *MockCloudWatchAlarmsClient) GetCallCount(operation string) int
- func (m *MockCloudWatchAlarmsClient) PutMetricAlarm(ctx context.Context, alarm *MockAlarmDefinition) error
- func (m *MockCloudWatchAlarmsClient) Reset()
- func (m *MockCloudWatchAlarmsClient) WithConfig(config *MockCloudWatchConfig) *MockCloudWatchAlarmsClient
- func (m *MockCloudWatchAlarmsClient) WithError(operation string, err error) *MockCloudWatchAlarmsClient
- func (m *MockCloudWatchAlarmsClient) WithMetricsClient(client *MockCloudWatchMetricsClient) *MockCloudWatchAlarmsClient
- type MockCloudWatchClient
- func (m *MockCloudWatchClient) DeleteAlarms(ctx context.Context, input *cloudwatch.DeleteAlarmsInput, ...) (*cloudwatch.DeleteAlarmsOutput, error)
- func (m *MockCloudWatchClient) DeleteAnomalyDetector(ctx context.Context, input *cloudwatch.DeleteAnomalyDetectorInput, ...) (*cloudwatch.DeleteAnomalyDetectorOutput, error)
- func (m *MockCloudWatchClient) DescribeAlarms(ctx context.Context, input *cloudwatch.DescribeAlarmsInput, ...) (*cloudwatch.DescribeAlarmsOutput, error)
- func (m *MockCloudWatchClient) DescribeAnomalyDetectors(ctx context.Context, input *cloudwatch.DescribeAnomalyDetectorsInput, ...) (*cloudwatch.DescribeAnomalyDetectorsOutput, error)
- func (m *MockCloudWatchClient) GetMetricData(ctx context.Context, input *cloudwatch.GetMetricDataInput, ...) (*cloudwatch.GetMetricDataOutput, error)
- func (m *MockCloudWatchClient) GetMetricStatistics(ctx context.Context, input *cloudwatch.GetMetricStatisticsInput, ...) (*cloudwatch.GetMetricStatisticsOutput, error)
- func (m *MockCloudWatchClient) ListMetrics(ctx context.Context, input *cloudwatch.ListMetricsInput, ...) (*cloudwatch.ListMetricsOutput, error)
- func (m *MockCloudWatchClient) ListTagsForResource(ctx context.Context, input *cloudwatch.ListTagsForResourceInput, ...) (*cloudwatch.ListTagsForResourceOutput, error)
- func (m *MockCloudWatchClient) PutAnomalyDetector(ctx context.Context, input *cloudwatch.PutAnomalyDetectorInput, ...) (*cloudwatch.PutAnomalyDetectorOutput, error)
- func (m *MockCloudWatchClient) PutMetricAlarm(ctx context.Context, input *cloudwatch.PutMetricAlarmInput, ...) (*cloudwatch.PutMetricAlarmOutput, error)
- func (m *MockCloudWatchClient) PutMetricData(ctx context.Context, input *cloudwatch.PutMetricDataInput, ...) (*cloudwatch.PutMetricDataOutput, error)
- func (m *MockCloudWatchClient) TagResource(ctx context.Context, input *cloudwatch.TagResourceInput, ...) (*cloudwatch.TagResourceOutput, error)
- func (m *MockCloudWatchClient) UntagResource(ctx context.Context, input *cloudwatch.UntagResourceInput, ...) (*cloudwatch.UntagResourceOutput, error)
- type MockCloudWatchConfig
- type MockCloudWatchMetricsClient
- func (m *MockCloudWatchMetricsClient) GetAllMetrics() map[string][]*MockMetricDatum
- func (m *MockCloudWatchMetricsClient) GetCallCount(operation string) int
- func (m *MockCloudWatchMetricsClient) GetMetricStatistics(ctx context.Context, namespace, metricName string, ...) (map[Statistic]float64, error)
- func (m *MockCloudWatchMetricsClient) GetMetrics(namespace string) []*MockMetricDatum
- func (m *MockCloudWatchMetricsClient) PutMetricData(ctx context.Context, namespace string, metricData []*MockMetricDatum) error
- func (m *MockCloudWatchMetricsClient) Reset()
- func (m *MockCloudWatchMetricsClient) WithConfig(config *MockCloudWatchConfig) *MockCloudWatchMetricsClient
- func (m *MockCloudWatchMetricsClient) WithError(operation string, err error) *MockCloudWatchMetricsClient
- type MockConnection
- type MockConnectionInfo
- type MockDynamORM
- func (m *MockDynamORM) BeginTransaction() (*MockTransaction, error)
- func (m *MockDynamORM) Delete(ctx context.Context, table, key string) error
- func (m *MockDynamORM) Get(ctx context.Context, table, key string, result any) error
- func (m *MockDynamORM) GetAllData() map[string]map[string]any
- func (m *MockDynamORM) Put(ctx context.Context, table, key string, item any) error
- func (m *MockDynamORM) Query(ctx context.Context, table string, query *dynamorm.Query) (*dynamorm.QueryResult, error)
- func (m *MockDynamORM) Reset()
- func (m *MockDynamORM) WithData(table, key string, item any) *MockDynamORM
- func (m *MockDynamORM) WithDelay(operation string, delay time.Duration) *MockDynamORM
- func (m *MockDynamORM) WithFailure(operation string, err error) *MockDynamORM
- type MockDynamORMWrapper
- func (w *MockDynamORMWrapper) BeginTransaction() (any, error)
- func (w *MockDynamORMWrapper) Delete(ctx context.Context, key any) error
- func (w *MockDynamORMWrapper) Get(ctx context.Context, key any, result any) error
- func (w *MockDynamORMWrapper) GetAllData() map[string]map[string]any
- func (w *MockDynamORMWrapper) Put(ctx context.Context, item any) error
- func (w *MockDynamORMWrapper) Query(ctx context.Context, query any) (any, error)
- func (w *MockDynamORMWrapper) WithData(key string, item any) *MockDynamORMWrapper
- func (w *MockDynamORMWrapper) WithFailure(operation string, err error) *MockDynamORMWrapper
- func (w *MockDynamORMWrapper) WithTenant(tenantID string) *MockDynamORMWrapper
- type MockHTTPClient
- type MockHTTPResponse
- type MockMetricDatum
- type MockTransaction
- type ScenarioRunner
- func (sr *ScenarioRunner) RunScenariosAdvanced(t *testing.T, scenarios []TestScenario)
- func (sr *ScenarioRunner) WithParallelExecution(enabled bool, maxConcurrency int) *ScenarioRunner
- func (sr *ScenarioRunner) WithRetry(attempts int, delay time.Duration) *ScenarioRunner
- func (sr *ScenarioRunner) WithTimeouts(setup, cleanup time.Duration) *ScenarioRunner
- type Statistic
- type StreamerAPIError
- type StreamerAPIGatewayClient
- type StreamerAPIGatewayClientMock
- func (m *StreamerAPIGatewayClientMock) DeleteConnection(ctx context.Context, connectionID string) error
- func (m *StreamerAPIGatewayClientMock) GetActiveConnections() map[string]*StreamerMockConnection
- func (m *StreamerAPIGatewayClientMock) GetCallCount(operation string) int
- func (m *StreamerAPIGatewayClientMock) GetConnection(ctx context.Context, connectionID string) (*StreamerConnectionInfo, error)
- func (m *StreamerAPIGatewayClientMock) GetConnectionState(connectionID string) *StreamerMockConnection
- func (m *StreamerAPIGatewayClientMock) GetMessageCount(connectionID string) int
- func (m *StreamerAPIGatewayClientMock) GetMessages(connectionID string) [][]byte
- func (m *StreamerAPIGatewayClientMock) PostToConnection(ctx context.Context, connectionID string, data []byte) error
- func (m *StreamerAPIGatewayClientMock) Reset()
- func (m *StreamerAPIGatewayClientMock) SimulateConnectionExpiry()
- func (m *StreamerAPIGatewayClientMock) WithConfig(config *StreamerMockConfig) *StreamerAPIGatewayClientMock
- func (m *StreamerAPIGatewayClientMock) WithConnection(connectionID string, conn *StreamerMockConnection) *StreamerAPIGatewayClientMock
- func (m *StreamerAPIGatewayClientMock) WithError(connectionID string, err error) *StreamerAPIGatewayClientMock
- func (m *StreamerAPIGatewayClientMock) WithForbiddenError(connectionID, message string) *StreamerAPIGatewayClientMock
- func (m *StreamerAPIGatewayClientMock) WithGoneError(connectionID, message string) *StreamerAPIGatewayClientMock
- func (m *StreamerAPIGatewayClientMock) WithInternalServerError(connectionID, message string) *StreamerAPIGatewayClientMock
- func (m *StreamerAPIGatewayClientMock) WithPayloadTooLargeError(connectionID string, payloadSize, maxSize int, message string) *StreamerAPIGatewayClientMock
- func (m *StreamerAPIGatewayClientMock) WithThrottlingError(connectionID string, retryAfter int, message string) *StreamerAPIGatewayClientMock
- type StreamerConnectionInfo
- type StreamerConnectionState
- type StreamerForbiddenError
- type StreamerGoneError
- type StreamerInternalServerError
- type StreamerMockConfig
- type StreamerMockConnection
- type StreamerPayloadTooLargeError
- type StreamerThrottlingError
- type TestApp
- func (ta *TestApp) App() *lift.App
- func (ta *TestApp) ClearHeaders() *TestApp
- func (ta *TestApp) DELETE(path string) *TestResponse
- func (ta *TestApp) GET(path string, query ...map[string]string) *TestResponse
- func (ta *TestApp) PATCH(path string, body any) *TestResponse
- func (ta *TestApp) POST(path string, body any) *TestResponse
- func (ta *TestApp) PUT(path string, body any) *TestResponse
- func (ta *TestApp) Start() error
- func (ta *TestApp) Stop()
- func (ta *TestApp) WithAuth(auth *AuthConfig) *TestApp
- func (ta *TestApp) WithHeader(key, value string) *TestApp
- func (ta *TestApp) WithHeaders(headers map[string]string) *TestApp
- type TestResponse
- func (r *TestResponse) AssertBodyContains(substring string) *TestResponse
- func (r *TestResponse) AssertBodyEquals(expected string) *TestResponse
- func (r *TestResponse) AssertError() *TestResponse
- func (r *TestResponse) AssertForbidden() *TestResponse
- func (r *TestResponse) AssertHasNextPage() *TestResponse
- func (r *TestResponse) AssertHasPrevPage() *TestResponse
- func (r *TestResponse) AssertHeader(key, expected string) *TestResponse
- func (r *TestResponse) AssertHeaderContains(key, substring string) *TestResponse
- func (r *TestResponse) AssertHeaderExists(key string) *TestResponse
- func (r *TestResponse) AssertJSONPath(path string, expected any) *TestResponse
- func (r *TestResponse) AssertJSONPathCount(path string, expectedCount int) *TestResponse
- func (r *TestResponse) AssertJSONPathExists(path string) *TestResponse
- func (r *TestResponse) AssertJSONPathNotExists(path string) *TestResponse
- func (r *TestResponse) AssertJSONPaths(assertions map[string]any) *TestResponse
- func (r *TestResponse) AssertJSONSchema(schema map[string]any) *TestResponse
- func (r *TestResponse) AssertNoError() *TestResponse
- func (r *TestResponse) AssertPagination(expectedTotal, expectedPage, expectedPerPage int) *TestResponse
- func (r *TestResponse) AssertRateLimitExceeded() *TestResponse
- func (r *TestResponse) AssertRateLimitHeaders() *TestResponse
- func (r *TestResponse) AssertRateLimitLimit(expected int) *TestResponse
- func (r *TestResponse) AssertRateLimitRemaining(expected int) *TestResponse
- func (r *TestResponse) AssertRequiresAuthentication() *TestResponse
- func (r *TestResponse) AssertResponseTime(maxDuration string) *TestResponse
- func (r *TestResponse) AssertStatus(expected int) *TestResponse
- func (r *TestResponse) AssertTenantIsolation(tenantID string) *TestResponse
- func (r *TestResponse) AssertUnauthorized() *TestResponse
- func (r *TestResponse) AssertValidationError(field string) *TestResponse
- func (r *TestResponse) AssertValidationErrors(fields []string) *TestResponse
- func (r *TestResponse) Chain(fn func(*TestResponse)) *TestResponse
- func (r *TestResponse) Debug() *TestResponse
- func (r *TestResponse) GetBody() string
- func (r *TestResponse) GetHeader(key string) string
- func (r *TestResponse) GetJSONPath(path string) any
- func (r *TestResponse) GetStatusCode() int
- func (r *TestResponse) IsSuccess() bool
- func (r *TestResponse) JSON(target any) error
- func (r *TestResponse) ParseJSON(target any) error
- type TestScenario
- func AuthenticationScenarios(endpoint string) []TestScenario
- func CRUDScenarios(basePath string, createData, updateData map[string]any) []TestScenario
- func ErrorHandlingScenarios() []TestScenario
- func MultiTenantScenarios(endpoint string) []TestScenario
- func PaginationScenarios(endpoint string, totalItems int) []TestScenario
- func PerformanceScenarios(endpoint string, maxResponseTime time.Duration) []TestScenario
- func RateLimitingScenarios(endpoint string, limit int) []TestScenario
- func ValidationScenarios(endpoint string, invalidData map[string]any, expectedErrors []string) []TestScenario
- type TransactionOperation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupTestData ¶
CleanupTestData removes test data
func CreateTestData ¶
CreateTestData creates test data for scenarios
func NewMockDatapoint ¶
func NewMockDatapoint(value float64, unit types.StandardUnit) types.Datapoint
NewMockDatapoint creates a mock Datapoint for testing
func NewMockDeleteAlarmsOutput ¶
func NewMockDeleteAlarmsOutput() *cloudwatch.DeleteAlarmsOutput
NewMockDeleteAlarmsOutput creates a mock DeleteAlarmsOutput
func NewMockDeleteAnomalyDetectorOutput ¶
func NewMockDeleteAnomalyDetectorOutput() *cloudwatch.DeleteAnomalyDetectorOutput
NewMockDeleteAnomalyDetectorOutput creates a mock DeleteAnomalyDetectorOutput
func NewMockDescribeAlarmsOutput ¶
func NewMockDescribeAlarmsOutput(alarms []types.MetricAlarm) *cloudwatch.DescribeAlarmsOutput
NewMockDescribeAlarmsOutput creates a mock DescribeAlarmsOutput with alarms
func NewMockDescribeAnomalyDetectorsOutput ¶
func NewMockDescribeAnomalyDetectorsOutput(detectors []types.AnomalyDetector) *cloudwatch.DescribeAnomalyDetectorsOutput
NewMockDescribeAnomalyDetectorsOutput creates a mock DescribeAnomalyDetectorsOutput
func NewMockDimension ¶
NewMockDimension creates a mock Dimension for testing
func NewMockGetMetricDataOutput ¶
func NewMockGetMetricDataOutput(results []types.MetricDataResult) *cloudwatch.GetMetricDataOutput
NewMockGetMetricDataOutput creates a mock GetMetricDataOutput with results
func NewMockGetMetricStatisticsOutput ¶
func NewMockGetMetricStatisticsOutput(datapoints []types.Datapoint) *cloudwatch.GetMetricStatisticsOutput
NewMockGetMetricStatisticsOutput creates a mock GetMetricStatisticsOutput with datapoints
func NewMockListMetricsOutput ¶
func NewMockListMetricsOutput(metrics []types.Metric) *cloudwatch.ListMetricsOutput
NewMockListMetricsOutput creates a mock ListMetricsOutput with metrics
func NewMockListTagsForResourceOutput ¶
func NewMockListTagsForResourceOutput(tags []types.Tag) *cloudwatch.ListTagsForResourceOutput
NewMockListTagsForResourceOutput creates a mock ListTagsForResourceOutput
func NewMockMetric ¶
NewMockMetric creates a mock Metric for testing
func NewMockMetricAlarm ¶
func NewMockMetricAlarm(name, metricName string, threshold float64) types.MetricAlarm
NewMockMetricAlarm creates a mock MetricAlarm for testing
func NewMockMetricDatum ¶
func NewMockMetricDatum(name string, value float64, unit types.StandardUnit) types.MetricDatum
NewMockMetricDatum creates a mock MetricDatum for testing
func NewMockPutAnomalyDetectorOutput ¶
func NewMockPutAnomalyDetectorOutput() *cloudwatch.PutAnomalyDetectorOutput
NewMockPutAnomalyDetectorOutput creates a mock PutAnomalyDetectorOutput
func NewMockPutMetricAlarmOutput ¶
func NewMockPutMetricAlarmOutput() *cloudwatch.PutMetricAlarmOutput
NewMockPutMetricAlarmOutput creates a mock PutMetricAlarmOutput
func NewMockPutMetricDataOutput ¶
func NewMockPutMetricDataOutput() *cloudwatch.PutMetricDataOutput
NewMockPutMetricDataOutput creates a mock PutMetricDataOutput
func NewMockTag ¶
NewMockTag creates a mock Tag for testing
func NewMockTagResourceOutput ¶
func NewMockTagResourceOutput() *cloudwatch.TagResourceOutput
NewMockTagResourceOutput creates a mock TagResourceOutput
func NewMockUntagResourceOutput ¶
func NewMockUntagResourceOutput() *cloudwatch.UntagResourceOutput
NewMockUntagResourceOutput creates a mock UntagResourceOutput
func RunScenarios ¶
func RunScenarios(t *testing.T, app *TestApp, scenarios []TestScenario)
RunScenarios executes a collection of test scenarios
Types ¶
type AlarmState ¶
type AlarmState string
AlarmState represents the state of a CloudWatch alarm
const ( AlarmStateOK AlarmState = "OK" AlarmStateAlarm AlarmState = "ALARM" AlarmStateInsufficientData AlarmState = "INSUFFICIENT_DATA" )
type AuthConfig ¶
AuthConfig holds authentication configuration for tests
type ComparisonOperator ¶
type ComparisonOperator string
ComparisonOperator represents alarm comparison operators
const ( ComparisonGreaterThanThreshold ComparisonOperator = "GreaterThanThreshold" ComparisonGreaterThanOrEqualToThreshold ComparisonOperator = "GreaterThanOrEqualToThreshold" ComparisonLessThanThreshold ComparisonOperator = "LessThanThreshold" ComparisonLessThanOrEqualToThreshold ComparisonOperator = "LessThanOrEqualToThreshold" ComparisonLessThanLowerOrGreaterThanUpperThreshold ComparisonOperator = "LessThanLowerOrGreaterThanUpperThreshold" ComparisonLessThanLowerThreshold ComparisonOperator = "LessThanLowerThreshold" ComparisonGreaterThanUpperThreshold ComparisonOperator = "GreaterThanUpperThreshold" )
type ConnectionState ¶
type ConnectionState string
ConnectionState represents the state of a WebSocket connection
const ( ConnectionStateActive ConnectionState = "ACTIVE" ConnectionStateDisconnected ConnectionState = "DISCONNECTED" ConnectionStateStale ConnectionState = "STALE" )
type LoadTestConfig ¶
type LoadTestConfig struct { ConcurrentUsers int `json:"concurrent_users"` TotalRequests int `json:"total_requests"` Duration time.Duration `json:"duration"` RampUpDuration time.Duration `json:"ramp_up_duration"` MaxLatency time.Duration `json:"max_latency"` ErrorThreshold float64 `json:"error_threshold"` RequestsPerSecond int `json:"requests_per_second"` }
LoadTestConfig configures load testing parameters
type LoadTestResult ¶
type LoadTestResult struct { TotalRequests int `json:"total_requests"` SuccessfulRequests int `json:"successful_requests"` FailedRequests int `json:"failed_requests"` AverageLatency time.Duration `json:"average_latency"` P95Latency time.Duration `json:"p95_latency"` P99Latency time.Duration `json:"p99_latency"` MaxLatency time.Duration `json:"max_latency"` MinLatency time.Duration `json:"min_latency"` RequestsPerSecond float64 `json:"requests_per_second"` ErrorRate float64 `json:"error_rate"` Duration time.Duration `json:"duration"` Errors []string `json:"errors"` StartTime time.Time `json:"start_time"` EndTime time.Time `json:"end_time"` }
LoadTestResult represents the result of a load test
type LoadTester ¶
type LoadTester struct {
// contains filtered or unexported fields
}
LoadTester provides load testing capabilities
func NewLoadTester ¶
func NewLoadTester(app *TestApp, config *LoadTestConfig) *LoadTester
NewLoadTester creates a new load tester
func (*LoadTester) RunLoadTest ¶
func (lt *LoadTester) RunLoadTest(ctx context.Context, request func(*TestApp) *TestResponse) (*LoadTestResult, error)
RunLoadTest executes a load test scenario
type MetricUnit ¶
type MetricUnit string
MetricUnit represents CloudWatch metric units
const ( MetricUnitNone MetricUnit = "None" MetricUnitSeconds MetricUnit = "Seconds" MetricUnitMicroseconds MetricUnit = "Microseconds" MetricUnitMilliseconds MetricUnit = "Milliseconds" MetricUnitBytes MetricUnit = "Bytes" MetricUnitKilobytes MetricUnit = "Kilobytes" MetricUnitMegabytes MetricUnit = "Megabytes" MetricUnitGigabytes MetricUnit = "Gigabytes" MetricUnitTerabytes MetricUnit = "Terabytes" MetricUnitBits MetricUnit = "Bits" MetricUnitKilobits MetricUnit = "Kilobits" MetricUnitMegabits MetricUnit = "Megabits" MetricUnitGigabits MetricUnit = "Gigabits" MetricUnitTerabits MetricUnit = "Terabits" MetricUnitPercent MetricUnit = "Percent" MetricUnitCount MetricUnit = "Count" MetricUnitCountPerSecond MetricUnit = "Count/Second" )
type MockAPIGatewayConfig ¶
type MockAPIGatewayConfig struct { // Connection TTL in seconds (default: 7200 = 2 hours) ConnectionTTL int64 // Maximum message size in bytes (default: 128KB) MaxMessageSize int64 // Simulate network delays NetworkDelay time.Duration // Error simulation rates (0.0 to 1.0) ErrorRates map[string]float64 }
MockAPIGatewayConfig configures the behavior of the API Gateway mock
func DefaultMockAPIGatewayConfig ¶
func DefaultMockAPIGatewayConfig() *MockAPIGatewayConfig
DefaultMockAPIGatewayConfig returns default configuration
type MockAPIGatewayError ¶
MockAPIGatewayError implements the APIError interface for testing
func (*MockAPIGatewayError) Error ¶
func (e *MockAPIGatewayError) Error() string
func (*MockAPIGatewayError) ErrorCode ¶
func (e *MockAPIGatewayError) ErrorCode() string
func (*MockAPIGatewayError) HTTPStatusCode ¶
func (e *MockAPIGatewayError) HTTPStatusCode() int
func (*MockAPIGatewayError) IsRetryable ¶
func (e *MockAPIGatewayError) IsRetryable() bool
type MockAPIGatewayManagementClient ¶
type MockAPIGatewayManagementClient struct {
// contains filtered or unexported fields
}
MockAPIGatewayManagementClient provides a mock implementation of API Gateway Management API
func NewMockAPIGatewayManagementClient ¶
func NewMockAPIGatewayManagementClient() *MockAPIGatewayManagementClient
NewMockAPIGatewayManagementClient creates a new mock API Gateway Management client
func (*MockAPIGatewayManagementClient) DeleteConnection ¶
func (m *MockAPIGatewayManagementClient) DeleteConnection(ctx context.Context, connectionID string) error
DeleteConnection terminates a WebSocket connection
func (*MockAPIGatewayManagementClient) GetActiveConnections ¶
func (m *MockAPIGatewayManagementClient) GetActiveConnections() map[string]*MockConnection
GetActiveConnections returns all active connections
func (*MockAPIGatewayManagementClient) GetCallCount ¶
func (m *MockAPIGatewayManagementClient) GetCallCount(operation string) int
GetCallCount returns the number of times an operation was called
func (*MockAPIGatewayManagementClient) GetConnection ¶
func (m *MockAPIGatewayManagementClient) GetConnection(ctx context.Context, connectionID string) (*MockConnectionInfo, error)
GetConnection retrieves connection information
func (*MockAPIGatewayManagementClient) GetConnectionState ¶
func (m *MockAPIGatewayManagementClient) GetConnectionState(connectionID string) *MockConnection
GetConnectionState returns a copy of the connection state
func (*MockAPIGatewayManagementClient) GetMessageCount ¶
func (m *MockAPIGatewayManagementClient) GetMessageCount(connectionID string) int
GetMessageCount returns the number of messages sent to a connection
func (*MockAPIGatewayManagementClient) GetMessages ¶
func (m *MockAPIGatewayManagementClient) GetMessages(connectionID string) [][]byte
GetMessages returns all messages sent to a connection
func (*MockAPIGatewayManagementClient) PostToConnection ¶
func (m *MockAPIGatewayManagementClient) PostToConnection(ctx context.Context, connectionID string, data []byte) error
PostToConnection sends data to a WebSocket connection
func (*MockAPIGatewayManagementClient) Reset ¶
func (m *MockAPIGatewayManagementClient) Reset()
Reset clears all mock state
func (*MockAPIGatewayManagementClient) SimulateConnectionExpiry ¶
func (m *MockAPIGatewayManagementClient) SimulateConnectionExpiry()
SimulateConnectionExpiry marks connections as stale based on TTL
func (*MockAPIGatewayManagementClient) WithConfig ¶
func (m *MockAPIGatewayManagementClient) WithConfig(config *MockAPIGatewayConfig) *MockAPIGatewayManagementClient
WithConfig sets the mock configuration
func (*MockAPIGatewayManagementClient) WithConnection ¶
func (m *MockAPIGatewayManagementClient) WithConnection(connectionID string, conn *MockConnection) *MockAPIGatewayManagementClient
WithConnection adds a connection to the mock
func (*MockAPIGatewayManagementClient) WithError ¶
func (m *MockAPIGatewayManagementClient) WithError(connectionID string, err error) *MockAPIGatewayManagementClient
WithError configures an error for a specific connection
type MockAWSService ¶
type MockAWSService struct {
// contains filtered or unexported fields
}
MockAWSService provides a generic mock for AWS services
func NewMockAWSService ¶
func NewMockAWSService() *MockAWSService
NewMockAWSService creates a new mock AWS service
func (*MockAWSService) Call ¶
func (m *MockAWSService) Call(operation string, input any) (any, error)
Call simulates calling an AWS service operation
func (*MockAWSService) GetCallCount ¶
func (m *MockAWSService) GetCallCount(operation string) int
GetCallCount returns the number of times an operation was called
func (*MockAWSService) WithError ¶
func (m *MockAWSService) WithError(operation string, err error) *MockAWSService
WithError configures an error for an operation
func (*MockAWSService) WithResponse ¶
func (m *MockAWSService) WithResponse(operation string, response any) *MockAWSService
WithResponse configures a response for an operation
type MockAlarmDefinition ¶
type MockAlarmDefinition struct { AlarmName string `json:"alarm_name"` AlarmDescription string `json:"alarm_description"` MetricName string `json:"metric_name"` Namespace string `json:"namespace"` Statistic Statistic `json:"statistic"` Dimensions map[string]string `json:"dimensions,omitempty"` Period int32 `json:"period"` EvaluationPeriods int32 `json:"evaluation_periods"` Threshold float64 `json:"threshold"` ComparisonOperator ComparisonOperator `json:"comparison_operator"` TreatMissingData string `json:"treat_missing_data"` State AlarmState `json:"state"` StateReason string `json:"state_reason"` StateUpdatedAt time.Time `json:"state_updated_at"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
MockAlarmDefinition represents a CloudWatch alarm
type MockCloudWatchAlarmsClient ¶
type MockCloudWatchAlarmsClient struct {
// contains filtered or unexported fields
}
MockCloudWatchAlarmsClient provides a mock implementation of CloudWatch Alarms
func NewMockCloudWatchAlarmsClient ¶
func NewMockCloudWatchAlarmsClient() *MockCloudWatchAlarmsClient
NewMockCloudWatchAlarmsClient creates a new mock CloudWatch Alarms client
func (*MockCloudWatchAlarmsClient) DeleteAlarms ¶
func (m *MockCloudWatchAlarmsClient) DeleteAlarms(ctx context.Context, alarmNames []string) error
DeleteAlarms deletes one or more alarms
func (*MockCloudWatchAlarmsClient) DescribeAlarms ¶
func (m *MockCloudWatchAlarmsClient) DescribeAlarms(ctx context.Context, alarmNames []string) ([]*MockAlarmDefinition, error)
DescribeAlarms retrieves alarm information
func (*MockCloudWatchAlarmsClient) EvaluateAlarms ¶
func (m *MockCloudWatchAlarmsClient) EvaluateAlarms(ctx context.Context) error
EvaluateAlarms evaluates all alarms against current metrics
func (*MockCloudWatchAlarmsClient) GetAlarm ¶
func (m *MockCloudWatchAlarmsClient) GetAlarm(alarmName string) *MockAlarmDefinition
GetAlarm returns a copy of an alarm definition
func (*MockCloudWatchAlarmsClient) GetAllAlarms ¶
func (m *MockCloudWatchAlarmsClient) GetAllAlarms() map[string]*MockAlarmDefinition
GetAllAlarms returns all alarm definitions
func (*MockCloudWatchAlarmsClient) GetCallCount ¶
func (m *MockCloudWatchAlarmsClient) GetCallCount(operation string) int
GetCallCount returns the number of times an operation was called
func (*MockCloudWatchAlarmsClient) PutMetricAlarm ¶
func (m *MockCloudWatchAlarmsClient) PutMetricAlarm(ctx context.Context, alarm *MockAlarmDefinition) error
PutMetricAlarm creates or updates an alarm
func (*MockCloudWatchAlarmsClient) Reset ¶
func (m *MockCloudWatchAlarmsClient) Reset()
Reset clears all mock state
func (*MockCloudWatchAlarmsClient) WithConfig ¶
func (m *MockCloudWatchAlarmsClient) WithConfig(config *MockCloudWatchConfig) *MockCloudWatchAlarmsClient
WithConfig sets the mock configuration
func (*MockCloudWatchAlarmsClient) WithError ¶
func (m *MockCloudWatchAlarmsClient) WithError(operation string, err error) *MockCloudWatchAlarmsClient
WithError configures an error for a specific operation
func (*MockCloudWatchAlarmsClient) WithMetricsClient ¶
func (m *MockCloudWatchAlarmsClient) WithMetricsClient(client *MockCloudWatchMetricsClient) *MockCloudWatchAlarmsClient
WithMetricsClient sets the metrics client for alarm evaluation
type MockCloudWatchClient ¶
MockCloudWatchClient provides a testify-based mock of the AWS CloudWatch client that implements the exact AWS SDK interface, following the DynamORM pattern.
func NewMockCloudWatchClient ¶
func NewMockCloudWatchClient() *MockCloudWatchClient
NewMockCloudWatchClient creates a new mock CloudWatch client
func (*MockCloudWatchClient) DeleteAlarms ¶
func (m *MockCloudWatchClient) DeleteAlarms( ctx context.Context, input *cloudwatch.DeleteAlarmsInput, optFns ...func(*cloudwatch.Options), ) (*cloudwatch.DeleteAlarmsOutput, error)
DeleteAlarms deletes one or more alarms
func (*MockCloudWatchClient) DeleteAnomalyDetector ¶
func (m *MockCloudWatchClient) DeleteAnomalyDetector( ctx context.Context, input *cloudwatch.DeleteAnomalyDetectorInput, optFns ...func(*cloudwatch.Options), ) (*cloudwatch.DeleteAnomalyDetectorOutput, error)
DeleteAnomalyDetector deletes an anomaly detector
func (*MockCloudWatchClient) DescribeAlarms ¶
func (m *MockCloudWatchClient) DescribeAlarms( ctx context.Context, input *cloudwatch.DescribeAlarmsInput, optFns ...func(*cloudwatch.Options), ) (*cloudwatch.DescribeAlarmsOutput, error)
DescribeAlarms retrieves alarm information
func (*MockCloudWatchClient) DescribeAnomalyDetectors ¶
func (m *MockCloudWatchClient) DescribeAnomalyDetectors( ctx context.Context, input *cloudwatch.DescribeAnomalyDetectorsInput, optFns ...func(*cloudwatch.Options), ) (*cloudwatch.DescribeAnomalyDetectorsOutput, error)
DescribeAnomalyDetectors retrieves anomaly detector information
func (*MockCloudWatchClient) GetMetricData ¶
func (m *MockCloudWatchClient) GetMetricData( ctx context.Context, input *cloudwatch.GetMetricDataInput, optFns ...func(*cloudwatch.Options), ) (*cloudwatch.GetMetricDataOutput, error)
GetMetricData retrieves metric data using metric queries
func (*MockCloudWatchClient) GetMetricStatistics ¶
func (m *MockCloudWatchClient) GetMetricStatistics( ctx context.Context, input *cloudwatch.GetMetricStatisticsInput, optFns ...func(*cloudwatch.Options), ) (*cloudwatch.GetMetricStatisticsOutput, error)
GetMetricStatistics retrieves statistics for a metric
func (*MockCloudWatchClient) ListMetrics ¶
func (m *MockCloudWatchClient) ListMetrics( ctx context.Context, input *cloudwatch.ListMetricsInput, optFns ...func(*cloudwatch.Options), ) (*cloudwatch.ListMetricsOutput, error)
ListMetrics lists available metrics
func (*MockCloudWatchClient) ListTagsForResource ¶
func (m *MockCloudWatchClient) ListTagsForResource( ctx context.Context, input *cloudwatch.ListTagsForResourceInput, optFns ...func(*cloudwatch.Options), ) (*cloudwatch.ListTagsForResourceOutput, error)
ListTagsForResource lists tags for a CloudWatch resource
func (*MockCloudWatchClient) PutAnomalyDetector ¶
func (m *MockCloudWatchClient) PutAnomalyDetector( ctx context.Context, input *cloudwatch.PutAnomalyDetectorInput, optFns ...func(*cloudwatch.Options), ) (*cloudwatch.PutAnomalyDetectorOutput, error)
PutAnomalyDetector creates or updates an anomaly detector
func (*MockCloudWatchClient) PutMetricAlarm ¶
func (m *MockCloudWatchClient) PutMetricAlarm( ctx context.Context, input *cloudwatch.PutMetricAlarmInput, optFns ...func(*cloudwatch.Options), ) (*cloudwatch.PutMetricAlarmOutput, error)
PutMetricAlarm creates or updates an alarm
func (*MockCloudWatchClient) PutMetricData ¶
func (m *MockCloudWatchClient) PutMetricData( ctx context.Context, input *cloudwatch.PutMetricDataInput, optFns ...func(*cloudwatch.Options), ) (*cloudwatch.PutMetricDataOutput, error)
PutMetricData publishes metric data to CloudWatch
func (*MockCloudWatchClient) TagResource ¶
func (m *MockCloudWatchClient) TagResource( ctx context.Context, input *cloudwatch.TagResourceInput, optFns ...func(*cloudwatch.Options), ) (*cloudwatch.TagResourceOutput, error)
TagResource adds tags to a CloudWatch resource
func (*MockCloudWatchClient) UntagResource ¶
func (m *MockCloudWatchClient) UntagResource( ctx context.Context, input *cloudwatch.UntagResourceInput, optFns ...func(*cloudwatch.Options), ) (*cloudwatch.UntagResourceOutput, error)
UntagResource removes tags from a CloudWatch resource
type MockCloudWatchConfig ¶
type MockCloudWatchConfig struct { // Maximum number of metrics per PutMetricData call MaxMetricsPerCall int // Simulate network delays NetworkDelay time.Duration // Auto-evaluate alarms when metrics are published AutoEvaluateAlarms bool // Metric retention period in hours MetricRetentionHours int }
MockCloudWatchConfig configures the behavior of CloudWatch mocks
func DefaultMockCloudWatchConfig ¶
func DefaultMockCloudWatchConfig() *MockCloudWatchConfig
DefaultMockCloudWatchConfig returns default configuration
type MockCloudWatchMetricsClient ¶
type MockCloudWatchMetricsClient struct {
// contains filtered or unexported fields
}
MockCloudWatchMetricsClient provides a mock implementation of CloudWatch Metrics
func NewMockCloudWatchMetricsClient ¶
func NewMockCloudWatchMetricsClient() *MockCloudWatchMetricsClient
NewMockCloudWatchMetricsClient creates a new mock CloudWatch Metrics client
func (*MockCloudWatchMetricsClient) GetAllMetrics ¶
func (m *MockCloudWatchMetricsClient) GetAllMetrics() map[string][]*MockMetricDatum
GetAllMetrics returns all metrics across all namespaces
func (*MockCloudWatchMetricsClient) GetCallCount ¶
func (m *MockCloudWatchMetricsClient) GetCallCount(operation string) int
GetCallCount returns the number of times an operation was called
func (*MockCloudWatchMetricsClient) GetMetricStatistics ¶
func (m *MockCloudWatchMetricsClient) GetMetricStatistics(ctx context.Context, namespace, metricName string, dimensions map[string]string, startTime, endTime time.Time, period int32, statistics []Statistic) (map[Statistic]float64, error)
GetMetricStatistics retrieves statistics for a metric
func (*MockCloudWatchMetricsClient) GetMetrics ¶
func (m *MockCloudWatchMetricsClient) GetMetrics(namespace string) []*MockMetricDatum
GetMetrics returns all metrics for a namespace
func (*MockCloudWatchMetricsClient) PutMetricData ¶
func (m *MockCloudWatchMetricsClient) PutMetricData(ctx context.Context, namespace string, metricData []*MockMetricDatum) error
PutMetricData publishes metric data to CloudWatch
func (*MockCloudWatchMetricsClient) Reset ¶
func (m *MockCloudWatchMetricsClient) Reset()
Reset clears all mock state
func (*MockCloudWatchMetricsClient) WithConfig ¶
func (m *MockCloudWatchMetricsClient) WithConfig(config *MockCloudWatchConfig) *MockCloudWatchMetricsClient
WithConfig sets the mock configuration
func (*MockCloudWatchMetricsClient) WithError ¶
func (m *MockCloudWatchMetricsClient) WithError(operation string, err error) *MockCloudWatchMetricsClient
WithError configures an error for a specific operation
type MockConnection ¶
type MockConnection struct { ID string `json:"id"` State ConnectionState `json:"state"` CreatedAt time.Time `json:"created_at"` LastActiveAt time.Time `json:"last_active_at"` SourceIP string `json:"source_ip"` UserAgent string `json:"user_agent"` Metadata map[string]any `json:"metadata,omitempty"` }
MockConnection represents a WebSocket connection in the mock
type MockConnectionInfo ¶
type MockConnectionInfo struct { ConnectionID string `json:"connectionId"` ConnectedAt string `json:"connectedAt"` LastActiveAt string `json:"lastActiveAt"` SourceIP string `json:"sourceIp"` UserAgent string `json:"userAgent"` }
MockConnectionInfo represents connection information returned by GetConnection
type MockDynamORM ¶
type MockDynamORM struct { // Behavior configuration FailOnOperation map[string]error // operation -> error to return Delays map[string]time.Duration // operation -> delay to add // contains filtered or unexported fields }
MockDynamORM provides a mock implementation of DynamORM for testing
func NewMockDynamORM ¶
func NewMockDynamORM() *MockDynamORM
NewMockDynamORM creates a new mock DynamORM instance
func (*MockDynamORM) BeginTransaction ¶
func (m *MockDynamORM) BeginTransaction() (*MockTransaction, error)
BeginTransaction starts a mock transaction
func (*MockDynamORM) Delete ¶
func (m *MockDynamORM) Delete(ctx context.Context, table, key string) error
Delete removes an item
func (*MockDynamORM) GetAllData ¶
func (m *MockDynamORM) GetAllData() map[string]map[string]any
GetAllData returns all data for testing inspection
func (*MockDynamORM) Query ¶
func (m *MockDynamORM) Query(ctx context.Context, table string, query *dynamorm.Query) (*dynamorm.QueryResult, error)
Query performs a query operation
func (*MockDynamORM) Reset ¶
func (m *MockDynamORM) Reset()
Reset clears all data and resets the mock state
func (*MockDynamORM) WithData ¶
func (m *MockDynamORM) WithData(table, key string, item any) *MockDynamORM
WithData pre-populates the mock with test data
func (*MockDynamORM) WithDelay ¶
func (m *MockDynamORM) WithDelay(operation string, delay time.Duration) *MockDynamORM
WithDelay configures the mock to add delays to operations
func (*MockDynamORM) WithFailure ¶
func (m *MockDynamORM) WithFailure(operation string, err error) *MockDynamORM
WithFailure configures the mock to fail on specific operations
type MockDynamORMWrapper ¶
type MockDynamORMWrapper struct {
// contains filtered or unexported fields
}
MockDynamORMWrapper wraps MockDynamORM to match the DynamORMWrapper interface
func NewMockDynamORMWrapper ¶
func NewMockDynamORMWrapper(tableName string) *MockDynamORMWrapper
NewMockDynamORMWrapper creates a wrapper that matches DynamORMWrapper interface
func (*MockDynamORMWrapper) BeginTransaction ¶
func (w *MockDynamORMWrapper) BeginTransaction() (any, error)
BeginTransaction starts a mock transaction
func (*MockDynamORMWrapper) Delete ¶
func (w *MockDynamORMWrapper) Delete(ctx context.Context, key any) error
Delete removes an item (matches DynamORMWrapper interface)
func (*MockDynamORMWrapper) GetAllData ¶
func (w *MockDynamORMWrapper) GetAllData() map[string]map[string]any
GetAllData returns all data for testing inspection
func (*MockDynamORMWrapper) Put ¶
func (w *MockDynamORMWrapper) Put(ctx context.Context, item any) error
Put saves an item (matches DynamORMWrapper interface)
func (*MockDynamORMWrapper) Query ¶
Query performs a query operation (matches DynamORMWrapper interface)
func (*MockDynamORMWrapper) WithData ¶
func (w *MockDynamORMWrapper) WithData(key string, item any) *MockDynamORMWrapper
WithData pre-populates the mock with test data
func (*MockDynamORMWrapper) WithFailure ¶
func (w *MockDynamORMWrapper) WithFailure(operation string, err error) *MockDynamORMWrapper
WithFailure configures the mock to fail on specific operations
func (*MockDynamORMWrapper) WithTenant ¶
func (w *MockDynamORMWrapper) WithTenant(tenantID string) *MockDynamORMWrapper
WithTenant creates a tenant-scoped wrapper
type MockHTTPClient ¶
type MockHTTPClient struct {
// contains filtered or unexported fields
}
MockHTTPClient provides a mock HTTP client for external API testing
func NewMockHTTPClient ¶
func NewMockHTTPClient() *MockHTTPClient
NewMockHTTPClient creates a new mock HTTP client
func (*MockHTTPClient) Get ¶
func (m *MockHTTPClient) Get(url string) (*MockHTTPResponse, error)
Get simulates an HTTP GET request
func (*MockHTTPClient) WithResponse ¶
func (m *MockHTTPClient) WithResponse(url string, response *MockHTTPResponse) *MockHTTPClient
WithResponse configures a response for a URL
type MockHTTPResponse ¶
type MockHTTPResponse struct { StatusCode int Body string Headers map[string]string Delay time.Duration }
MockHTTPResponse represents a mock HTTP response
type MockMetricDatum ¶
type MockMetricDatum struct { MetricName string `json:"metric_name"` Value float64 `json:"value"` Unit MetricUnit `json:"unit"` Timestamp time.Time `json:"timestamp"` Dimensions map[string]string `json:"dimensions,omitempty"` Metadata map[string]any `json:"metadata,omitempty"` }
MockMetricDatum represents a single metric data point
type MockTransaction ¶
type MockTransaction struct {
// contains filtered or unexported fields
}
MockTransaction represents a mock DynamORM transaction
func (*MockTransaction) Commit ¶
func (tx *MockTransaction) Commit() error
Commit commits the transaction
func (*MockTransaction) Delete ¶
func (tx *MockTransaction) Delete(ctx context.Context, table, key string) error
Delete adds a delete operation to the transaction
func (*MockTransaction) Rollback ¶
func (tx *MockTransaction) Rollback() error
Rollback rolls back the transaction
type ScenarioRunner ¶
type ScenarioRunner struct {
// contains filtered or unexported fields
}
ScenarioRunner provides advanced scenario execution capabilities
func NewScenarioRunner ¶
func NewScenarioRunner(app *TestApp) *ScenarioRunner
NewScenarioRunner creates a new scenario runner with advanced capabilities
func (*ScenarioRunner) RunScenariosAdvanced ¶
func (sr *ScenarioRunner) RunScenariosAdvanced(t *testing.T, scenarios []TestScenario)
RunScenariosAdvanced executes scenarios with advanced features
func (*ScenarioRunner) WithParallelExecution ¶
func (sr *ScenarioRunner) WithParallelExecution(enabled bool, maxConcurrency int) *ScenarioRunner
WithParallelExecution configures parallel execution
func (*ScenarioRunner) WithRetry ¶
func (sr *ScenarioRunner) WithRetry(attempts int, delay time.Duration) *ScenarioRunner
WithRetry configures retry behavior
func (*ScenarioRunner) WithTimeouts ¶
func (sr *ScenarioRunner) WithTimeouts(setup, cleanup time.Duration) *ScenarioRunner
WithTimeouts configures timeouts
type StreamerAPIError ¶
type StreamerAPIError interface { error HTTPStatusCode() int ErrorCode() string IsRetryable() bool }
StreamerAPIError matches streamer's APIError interface
type StreamerAPIGatewayClient ¶
type StreamerAPIGatewayClient interface { PostToConnection(ctx context.Context, connectionID string, data []byte) error DeleteConnection(ctx context.Context, connectionID string) error GetConnection(ctx context.Context, connectionID string) (*StreamerConnectionInfo, error) }
StreamerAPIGatewayClient defines the interface that matches streamer's APIGatewayClient
type StreamerAPIGatewayClientMock ¶
type StreamerAPIGatewayClientMock struct {
// contains filtered or unexported fields
}
StreamerAPIGatewayClientMock implements the StreamerAPIGatewayClient interface
func NewStreamerAPIGatewayClientMock ¶
func NewStreamerAPIGatewayClientMock() *StreamerAPIGatewayClientMock
NewStreamerAPIGatewayClientMock creates a new streamer-compatible API Gateway client mock
func (*StreamerAPIGatewayClientMock) DeleteConnection ¶
func (m *StreamerAPIGatewayClientMock) DeleteConnection(ctx context.Context, connectionID string) error
DeleteConnection terminates a WebSocket connection Implements StreamerAPIGatewayClient interface
func (*StreamerAPIGatewayClientMock) GetActiveConnections ¶
func (m *StreamerAPIGatewayClientMock) GetActiveConnections() map[string]*StreamerMockConnection
GetActiveConnections returns all active connections
func (*StreamerAPIGatewayClientMock) GetCallCount ¶
func (m *StreamerAPIGatewayClientMock) GetCallCount(operation string) int
GetCallCount returns the number of times an operation was called
func (*StreamerAPIGatewayClientMock) GetConnection ¶
func (m *StreamerAPIGatewayClientMock) GetConnection(ctx context.Context, connectionID string) (*StreamerConnectionInfo, error)
GetConnection retrieves connection information Implements StreamerAPIGatewayClient interface
func (*StreamerAPIGatewayClientMock) GetConnectionState ¶
func (m *StreamerAPIGatewayClientMock) GetConnectionState(connectionID string) *StreamerMockConnection
GetConnectionState returns a copy of the connection state
func (*StreamerAPIGatewayClientMock) GetMessageCount ¶
func (m *StreamerAPIGatewayClientMock) GetMessageCount(connectionID string) int
GetMessageCount returns the number of messages sent to a connection
func (*StreamerAPIGatewayClientMock) GetMessages ¶
func (m *StreamerAPIGatewayClientMock) GetMessages(connectionID string) [][]byte
GetMessages returns all messages sent to a connection
func (*StreamerAPIGatewayClientMock) PostToConnection ¶
func (m *StreamerAPIGatewayClientMock) PostToConnection(ctx context.Context, connectionID string, data []byte) error
PostToConnection sends data to a WebSocket connection Implements StreamerAPIGatewayClient interface
func (*StreamerAPIGatewayClientMock) Reset ¶
func (m *StreamerAPIGatewayClientMock) Reset()
Reset clears all mock state
func (*StreamerAPIGatewayClientMock) SimulateConnectionExpiry ¶
func (m *StreamerAPIGatewayClientMock) SimulateConnectionExpiry()
SimulateConnectionExpiry marks connections as stale based on TTL
func (*StreamerAPIGatewayClientMock) WithConfig ¶
func (m *StreamerAPIGatewayClientMock) WithConfig(config *StreamerMockConfig) *StreamerAPIGatewayClientMock
WithConfig sets the mock configuration
func (*StreamerAPIGatewayClientMock) WithConnection ¶
func (m *StreamerAPIGatewayClientMock) WithConnection(connectionID string, conn *StreamerMockConnection) *StreamerAPIGatewayClientMock
WithConnection adds a connection to the mock
func (*StreamerAPIGatewayClientMock) WithError ¶
func (m *StreamerAPIGatewayClientMock) WithError(connectionID string, err error) *StreamerAPIGatewayClientMock
WithError configures an error for a specific connection
func (*StreamerAPIGatewayClientMock) WithForbiddenError ¶
func (m *StreamerAPIGatewayClientMock) WithForbiddenError(connectionID, message string) *StreamerAPIGatewayClientMock
WithForbiddenError configures a ForbiddenError for a specific connection
func (*StreamerAPIGatewayClientMock) WithGoneError ¶
func (m *StreamerAPIGatewayClientMock) WithGoneError(connectionID, message string) *StreamerAPIGatewayClientMock
WithGoneError configures a GoneError for a specific connection
func (*StreamerAPIGatewayClientMock) WithInternalServerError ¶
func (m *StreamerAPIGatewayClientMock) WithInternalServerError(connectionID, message string) *StreamerAPIGatewayClientMock
WithInternalServerError configures an InternalServerError for a specific connection
func (*StreamerAPIGatewayClientMock) WithPayloadTooLargeError ¶
func (m *StreamerAPIGatewayClientMock) WithPayloadTooLargeError(connectionID string, payloadSize, maxSize int, message string) *StreamerAPIGatewayClientMock
WithPayloadTooLargeError configures a PayloadTooLargeError for a specific connection
func (*StreamerAPIGatewayClientMock) WithThrottlingError ¶
func (m *StreamerAPIGatewayClientMock) WithThrottlingError(connectionID string, retryAfter int, message string) *StreamerAPIGatewayClientMock
WithThrottlingError configures a ThrottlingError for a specific connection
type StreamerConnectionInfo ¶
type StreamerConnectionInfo struct { ConnectionID string ConnectedAt string LastActiveAt string SourceIP string UserAgent string }
StreamerConnectionInfo matches streamer's ConnectionInfo struct
type StreamerConnectionState ¶
type StreamerConnectionState string
StreamerConnectionState represents the state of a connection
const ( StreamerConnectionStateActive StreamerConnectionState = "ACTIVE" StreamerConnectionStateDisconnected StreamerConnectionState = "DISCONNECTED" StreamerConnectionStateStale StreamerConnectionState = "STALE" )
type StreamerForbiddenError ¶
Streamer-compatible error types that match their exact implementation
func (StreamerForbiddenError) Error ¶
func (e StreamerForbiddenError) Error() string
func (StreamerForbiddenError) ErrorCode ¶
func (e StreamerForbiddenError) ErrorCode() string
func (StreamerForbiddenError) HTTPStatusCode ¶
func (e StreamerForbiddenError) HTTPStatusCode() int
func (StreamerForbiddenError) IsRetryable ¶
func (e StreamerForbiddenError) IsRetryable() bool
type StreamerGoneError ¶
Streamer-compatible error types that match their exact implementation
func (StreamerGoneError) Error ¶
func (e StreamerGoneError) Error() string
Error implementations for streamer-compatible errors
func (StreamerGoneError) ErrorCode ¶
func (e StreamerGoneError) ErrorCode() string
func (StreamerGoneError) HTTPStatusCode ¶
func (e StreamerGoneError) HTTPStatusCode() int
func (StreamerGoneError) IsRetryable ¶
func (e StreamerGoneError) IsRetryable() bool
type StreamerInternalServerError ¶
type StreamerInternalServerError struct {
Message string
}
Streamer-compatible error types that match their exact implementation
func (StreamerInternalServerError) Error ¶
func (e StreamerInternalServerError) Error() string
func (StreamerInternalServerError) ErrorCode ¶
func (e StreamerInternalServerError) ErrorCode() string
func (StreamerInternalServerError) HTTPStatusCode ¶
func (e StreamerInternalServerError) HTTPStatusCode() int
func (StreamerInternalServerError) IsRetryable ¶
func (e StreamerInternalServerError) IsRetryable() bool
type StreamerMockConfig ¶
type StreamerMockConfig struct { ConnectionTTL int64 // Connection TTL in seconds (default: 7200 = 2 hours) MaxMessageSize int64 // Maximum message size in bytes (default: 128KB) NetworkDelay time.Duration // Simulate network delays DefaultSourceIP string // Default connection source IP DefaultUserAgent string // Default connection user agent }
StreamerMockConfig configures the behavior of the streamer-compatible mock
func DefaultStreamerMockConfig ¶
func DefaultStreamerMockConfig() *StreamerMockConfig
DefaultStreamerMockConfig returns default configuration for streamer mocks
type StreamerMockConnection ¶
type StreamerMockConnection struct { ConnectionID string ConnectedAt string LastActiveAt string SourceIP string UserAgent string State StreamerConnectionState CreatedTime time.Time Metadata map[string]any }
StreamerMockConnection represents a WebSocket connection in the streamer-compatible mock
type StreamerPayloadTooLargeError ¶
type StreamerPayloadTooLargeError struct { ConnectionID string PayloadSize int MaxSize int Message string }
Streamer-compatible error types that match their exact implementation
func (StreamerPayloadTooLargeError) Error ¶
func (e StreamerPayloadTooLargeError) Error() string
func (StreamerPayloadTooLargeError) ErrorCode ¶
func (e StreamerPayloadTooLargeError) ErrorCode() string
func (StreamerPayloadTooLargeError) HTTPStatusCode ¶
func (e StreamerPayloadTooLargeError) HTTPStatusCode() int
func (StreamerPayloadTooLargeError) IsRetryable ¶
func (e StreamerPayloadTooLargeError) IsRetryable() bool
type StreamerThrottlingError ¶
Streamer-compatible error types that match their exact implementation
func (StreamerThrottlingError) Error ¶
func (e StreamerThrottlingError) Error() string
func (StreamerThrottlingError) ErrorCode ¶
func (e StreamerThrottlingError) ErrorCode() string
func (StreamerThrottlingError) HTTPStatusCode ¶
func (e StreamerThrottlingError) HTTPStatusCode() int
func (StreamerThrottlingError) IsRetryable ¶
func (e StreamerThrottlingError) IsRetryable() bool
type TestApp ¶
type TestApp struct {
// contains filtered or unexported fields
}
TestApp represents a test application instance
func NewTestApp ¶
func NewTestApp() *TestApp
NewTestApp creates a new test application with a default Lift app
func (*TestApp) ClearHeaders ¶
ClearHeaders clears all headers
func (*TestApp) DELETE ¶
func (ta *TestApp) DELETE(path string) *TestResponse
DELETE performs a DELETE request
func (*TestApp) GET ¶
func (ta *TestApp) GET(path string, query ...map[string]string) *TestResponse
GET performs a GET request with optional query parameters
func (*TestApp) PATCH ¶
func (ta *TestApp) PATCH(path string, body any) *TestResponse
PATCH performs a PATCH request
func (*TestApp) POST ¶
func (ta *TestApp) POST(path string, body any) *TestResponse
POST performs a POST request
func (*TestApp) PUT ¶
func (ta *TestApp) PUT(path string, body any) *TestResponse
PUT performs a PUT request
func (*TestApp) WithAuth ¶
func (ta *TestApp) WithAuth(auth *AuthConfig) *TestApp
WithAuth sets authentication for subsequent requests
func (*TestApp) WithHeader ¶
WithHeader adds a header for subsequent requests
type TestResponse ¶
type TestResponse struct { StatusCode int Headers map[string]string Body string // contains filtered or unexported fields }
TestResponse provides enhanced assertion capabilities for HTTP responses
func NewTestResponse ¶
func NewTestResponse(t *testing.T, statusCode int, headers map[string]string, body []byte, err error) *TestResponse
NewTestResponse creates a new TestResponse for testing
func (*TestResponse) AssertBodyContains ¶
func (r *TestResponse) AssertBodyContains(substring string) *TestResponse
AssertBodyContains verifies the response body contains a substring
func (*TestResponse) AssertBodyEquals ¶
func (r *TestResponse) AssertBodyEquals(expected string) *TestResponse
AssertBodyEquals verifies the response body exactly matches
func (*TestResponse) AssertError ¶
func (r *TestResponse) AssertError() *TestResponse
AssertError verifies an error occurred
func (*TestResponse) AssertForbidden ¶
func (r *TestResponse) AssertForbidden() *TestResponse
AssertForbidden verifies forbidden response
func (*TestResponse) AssertHasNextPage ¶
func (r *TestResponse) AssertHasNextPage() *TestResponse
AssertHasNextPage verifies next page link exists
func (*TestResponse) AssertHasPrevPage ¶
func (r *TestResponse) AssertHasPrevPage() *TestResponse
AssertHasPrevPage verifies previous page link exists
func (*TestResponse) AssertHeader ¶
func (r *TestResponse) AssertHeader(key, expected string) *TestResponse
AssertHeader verifies a specific header value
func (*TestResponse) AssertHeaderContains ¶
func (r *TestResponse) AssertHeaderContains(key, substring string) *TestResponse
AssertHeaderContains verifies a header contains a substring
func (*TestResponse) AssertHeaderExists ¶
func (r *TestResponse) AssertHeaderExists(key string) *TestResponse
AssertHeaderExists verifies a header exists
func (*TestResponse) AssertJSONPath ¶
func (r *TestResponse) AssertJSONPath(path string, expected any) *TestResponse
AssertJSONPath verifies a JSON path matches expected value
func (*TestResponse) AssertJSONPathCount ¶
func (r *TestResponse) AssertJSONPathCount(path string, expectedCount int) *TestResponse
AssertJSONPathCount verifies the count of items at a JSON path
func (*TestResponse) AssertJSONPathExists ¶
func (r *TestResponse) AssertJSONPathExists(path string) *TestResponse
AssertJSONPathExists verifies a JSON path exists
func (*TestResponse) AssertJSONPathNotExists ¶
func (r *TestResponse) AssertJSONPathNotExists(path string) *TestResponse
AssertJSONPathNotExists verifies a JSON path does not exist
func (*TestResponse) AssertJSONPaths ¶
func (r *TestResponse) AssertJSONPaths(assertions map[string]any) *TestResponse
AssertJSONPaths verifies multiple JSON paths at once
func (*TestResponse) AssertJSONSchema ¶
func (r *TestResponse) AssertJSONSchema(schema map[string]any) *TestResponse
AssertJSONSchema verifies the response matches a JSON schema (basic validation)
func (*TestResponse) AssertNoError ¶
func (r *TestResponse) AssertNoError() *TestResponse
AssertNoError verifies no error occurred
func (*TestResponse) AssertPagination ¶
func (r *TestResponse) AssertPagination(expectedTotal, expectedPage, expectedPerPage int) *TestResponse
AssertPagination verifies pagination metadata
func (*TestResponse) AssertRateLimitExceeded ¶
func (r *TestResponse) AssertRateLimitExceeded() *TestResponse
AssertRateLimitExceeded verifies a rate limit exceeded response
func (*TestResponse) AssertRateLimitHeaders ¶
func (r *TestResponse) AssertRateLimitHeaders() *TestResponse
AssertRateLimitHeaders verifies standard rate limit headers are present
func (*TestResponse) AssertRateLimitLimit ¶
func (r *TestResponse) AssertRateLimitLimit(expected int) *TestResponse
AssertRateLimitLimit verifies the rate limit value
func (*TestResponse) AssertRateLimitRemaining ¶
func (r *TestResponse) AssertRateLimitRemaining(expected int) *TestResponse
AssertRateLimitRemaining verifies the remaining rate limit count
func (*TestResponse) AssertRequiresAuthentication ¶
func (r *TestResponse) AssertRequiresAuthentication() *TestResponse
AssertRequiresAuthentication verifies authentication is required
func (*TestResponse) AssertResponseTime ¶
func (r *TestResponse) AssertResponseTime(maxDuration string) *TestResponse
AssertResponseTime verifies response was fast enough
func (*TestResponse) AssertStatus ¶
func (r *TestResponse) AssertStatus(expected int) *TestResponse
AssertStatus verifies the HTTP status code
func (*TestResponse) AssertTenantIsolation ¶
func (r *TestResponse) AssertTenantIsolation(tenantID string) *TestResponse
AssertTenantIsolation verifies tenant-specific data isolation
func (*TestResponse) AssertUnauthorized ¶
func (r *TestResponse) AssertUnauthorized() *TestResponse
AssertUnauthorized verifies unauthorized response
func (*TestResponse) AssertValidationError ¶
func (r *TestResponse) AssertValidationError(field string) *TestResponse
AssertValidationError verifies a validation error response
func (*TestResponse) AssertValidationErrors ¶
func (r *TestResponse) AssertValidationErrors(fields []string) *TestResponse
AssertValidationErrors verifies multiple validation errors
func (*TestResponse) Chain ¶
func (r *TestResponse) Chain(fn func(*TestResponse)) *TestResponse
Chain allows for custom assertions
func (*TestResponse) Debug ¶
func (r *TestResponse) Debug() *TestResponse
Debug prints the response for debugging
func (*TestResponse) GetBody ¶
func (r *TestResponse) GetBody() string
GetBody returns the response body as string
func (*TestResponse) GetHeader ¶
func (r *TestResponse) GetHeader(key string) string
GetHeader returns a header value
func (*TestResponse) GetJSONPath ¶
func (r *TestResponse) GetJSONPath(path string) any
GetJSONPath extracts a value from the JSON response
func (*TestResponse) GetStatusCode ¶
func (r *TestResponse) GetStatusCode() int
GetStatusCode returns the HTTP status code
func (*TestResponse) IsSuccess ¶
func (r *TestResponse) IsSuccess() bool
IsSuccess returns true if the status code indicates success (2xx)
func (*TestResponse) JSON ¶
func (r *TestResponse) JSON(target any) error
JSON parses the response body as JSON into the provided interface
func (*TestResponse) ParseJSON ¶
func (r *TestResponse) ParseJSON(target any) error
ParseJSON parses the response body as JSON
type TestScenario ¶
type TestScenario struct { Name string Description string Setup func(*TestApp) error Request func(*TestApp) *TestResponse Assertions func(*testing.T, *TestResponse) Cleanup func(*TestApp) error Skip bool SkipReason string }
TestScenario represents a complete test scenario
func AuthenticationScenarios ¶
func AuthenticationScenarios(endpoint string) []TestScenario
AuthenticationScenarios returns common authentication test scenarios
func CRUDScenarios ¶
func CRUDScenarios(basePath string, createData, updateData map[string]any) []TestScenario
CRUDScenarios returns common CRUD operation test scenarios
func ErrorHandlingScenarios ¶
func ErrorHandlingScenarios() []TestScenario
ErrorHandlingScenarios returns error handling test scenarios
func MultiTenantScenarios ¶
func MultiTenantScenarios(endpoint string) []TestScenario
MultiTenantScenarios returns common multi-tenant test scenarios
func PaginationScenarios ¶
func PaginationScenarios(endpoint string, totalItems int) []TestScenario
PaginationScenarios returns pagination test scenarios
func PerformanceScenarios ¶
func PerformanceScenarios(endpoint string, maxResponseTime time.Duration) []TestScenario
PerformanceScenarios returns performance-related test scenarios
func RateLimitingScenarios ¶
func RateLimitingScenarios(endpoint string, limit int) []TestScenario
RateLimitingScenarios returns common rate limiting test scenarios
func ValidationScenarios ¶
func ValidationScenarios(endpoint string, invalidData map[string]any, expectedErrors []string) []TestScenario
ValidationScenarios returns common validation test scenarios