Documentation
¶
Overview ¶
Package mocks provides comprehensive mock implementations for testing AhaSend CLI components.
This package implements standardized mock objects using the testify/mock framework:
- MockClient: Complete AhaSendClient interface implementation
- MockConfigManager: Full ConfigManager interface implementation
- Interface compliance verification at compile time
- Helper methods for creating common test data structures
- Consistent error handling patterns for test scenarios
- Documentation and examples for proper usage patterns
All mocks follow the same interface-based design patterns as production code, enabling comprehensive testing without external dependencies while maintaining type safety and interface compliance.
Index ¶
- type MockClient
- func (m *MockClient) CancelMessage(accountID, messageID string) (*common.SuccessResponse, error)
- func (m *MockClient) CheckSuppression(email string, domain *string) (bool, *responses.Suppression, error)
- func (m *MockClient) ConnectWebSocket(wsURL, webhookID string, forceReconnect, skipVerify bool) (*client.WebSocketClient, error)
- func (m *MockClient) CreateAPIKey(req requests.CreateAPIKeyRequest) (*responses.APIKey, error)
- func (m *MockClient) CreateDomain(domain string) (*responses.Domain, error)
- func (m *MockClient) CreateRoute(req requests.CreateRouteRequest) (*responses.Route, error)
- func (m *MockClient) CreateSMTPCredential(req requests.CreateSMTPCredentialRequest) (*responses.SMTPCredential, error)
- func (m *MockClient) CreateSuppression(req requests.CreateSuppressionRequest) (*responses.CreateSuppressionResponse, error)
- func (m *MockClient) CreateWebhook(req requests.CreateWebhookRequest) (*responses.Webhook, error)
- func (m *MockClient) CreateWebhookVerifier(secret string) (*webhooks.WebhookVerifier, error)
- func (m *MockClient) DeleteAPIKey(keyID string) (*common.SuccessResponse, error)
- func (m *MockClient) DeleteDomain(domain string) (*common.SuccessResponse, error)
- func (m *MockClient) DeleteRoute(routeID string) error
- func (m *MockClient) DeleteSMTPCredential(credentialID string) error
- func (m *MockClient) DeleteSuppression(email string, domain *string) (*common.SuccessResponse, error)
- func (m *MockClient) DeleteWebhook(webhookID string) error
- func (m *MockClient) GetAPIKey(keyID string) (*responses.APIKey, error)
- func (m *MockClient) GetAccount() (*responses.Account, error)
- func (m *MockClient) GetAccountID() string
- func (m *MockClient) GetAuthContext() context.Context
- func (m *MockClient) GetBounceStatistics(params requests.GetBounceStatisticsParams) (*responses.BounceStatisticsResponse, error)
- func (m *MockClient) GetDeliverabilityStatistics(params requests.GetDeliverabilityStatisticsParams) (*responses.DeliverabilityStatisticsResponse, error)
- func (m *MockClient) GetDeliveryTimeStatistics(params requests.GetDeliveryTimeStatisticsParams) (*responses.DeliveryTimeStatisticsResponse, error)
- func (m *MockClient) GetDomain(domain string) (*responses.Domain, error)
- func (m *MockClient) GetMessages(params requests.GetMessagesParams) (*responses.PaginatedMessagesResponse, error)
- func (m *MockClient) GetRoute(routeID string) (*responses.Route, error)
- func (m *MockClient) GetSMTPCredential(credentialID string) (*responses.SMTPCredential, error)
- func (m *MockClient) GetWebhook(webhookID string) (*responses.Webhook, error)
- func (m *MockClient) InitiateWebhookStream(webhookID string) (*client.WebhookStreamResponse, error)
- func (m *MockClient) ListAPIKeys(limit *int32, cursor *string) (*responses.PaginatedAPIKeysResponse, error)
- func (m *MockClient) ListDomains(limit *int32, cursor *string) (*responses.PaginatedDomainsResponse, error)
- func (m *MockClient) ListRoutes(limit *int32, cursor *string) (*responses.PaginatedRoutesResponse, error)
- func (m *MockClient) ListSMTPCredentials(limit *int32, cursor *string) (*responses.PaginatedSMTPCredentialsResponse, error)
- func (m *MockClient) ListSuppressions(params requests.GetSuppressionsParams) (*responses.PaginatedSuppressionsResponse, error)
- func (m *MockClient) ListWebhooks(limit *int32, cursor *string) (*responses.PaginatedWebhooksResponse, error)
- func (m *MockClient) NewMockDomain(domain string, valid bool) *responses.Domain
- func (m *MockClient) NewMockDomainsResponse(domains []responses.Domain, hasMore bool) *responses.PaginatedDomainsResponse
- func (m *MockClient) NewMockMessageResponse(messageID string) *responses.CreateMessageResponse
- func (m *MockClient) NewMockMessagesResponse(messages []responses.Message, hasMore bool) *responses.PaginatedMessagesResponse
- func (m *MockClient) NewMockRoute(idStr, name, url, recipientFilter string, enabled bool) *responses.Route
- func (m *MockClient) NewMockRouteWithOptions(idStr, name, url string, enabled bool, options map[string]bool) *responses.Route
- func (m *MockClient) NewMockRoutesResponse(routes []responses.Route, hasMore bool) *responses.PaginatedRoutesResponse
- func (m *MockClient) NewMockSMTPCredential(id uint64, name, username, scope string, sandbox bool, domains []string) *responses.SMTPCredential
- func (m *MockClient) NewMockSMTPCredentialsResponse(credentials []responses.SMTPCredential, hasMore bool) *responses.PaginatedSMTPCredentialsResponse
- func (m *MockClient) NewMockSuppression(email, reason, domain string) *responses.Suppression
- func (m *MockClient) NewMockSuppressionWithExpiry(email, reason, domain string, expiresIn time.Duration) *responses.Suppression
- func (m *MockClient) NewMockSuppressionsResponse(suppressions []responses.Suppression, hasMore bool) *responses.PaginatedSuppressionsResponse
- func (m *MockClient) NewMockWebhook(idStr, name, url string, enabled bool) responses.Webhook
- func (m *MockClient) NewMockWebhooksResponse(webhooks []responses.Webhook, hasMore bool) *responses.PaginatedWebhooksResponse
- func (m *MockClient) Ping() error
- func (m *MockClient) SendMessage(req requests.CreateMessageRequest) (*responses.CreateMessageResponse, error)
- func (m *MockClient) SendMessageWithIdempotencyKey(req requests.CreateMessageRequest, idempotencyKey string) (*responses.CreateMessageResponse, error)
- func (m *MockClient) TriggerWebhook(webhookID string, events []string) error
- func (m *MockClient) UpdateAPIKey(keyID string, req requests.UpdateAPIKeyRequest) (*responses.APIKey, error)
- func (m *MockClient) UpdateRoute(routeID string, req requests.UpdateRouteRequest) (*responses.Route, error)
- func (m *MockClient) UpdateWebhook(webhookID string, req requests.UpdateWebhookRequest) (*responses.Webhook, error)
- func (m *MockClient) ValidateConfiguration() error
- func (m *MockClient) WipeSuppressions(domain *string) (*common.SuccessResponse, error)
- type MockConfigManager
- func (m *MockConfigManager) GetConfig() *config.Config
- func (m *MockConfigManager) GetCurrentProfile() (*config.Profile, error)
- func (m *MockConfigManager) GetPreference(key string) (string, error)
- func (m *MockConfigManager) ListProfiles() []string
- func (m *MockConfigManager) Load() error
- func (m *MockConfigManager) NewMockConfig() *config.Config
- func (m *MockConfigManager) NewMockProfile(name, apiKey, accountID string) config.Profile
- func (m *MockConfigManager) RemoveProfile(name string) error
- func (m *MockConfigManager) Save() error
- func (m *MockConfigManager) SetDefaultProfile(name string) error
- func (m *MockConfigManager) SetPreference(key, value string) error
- func (m *MockConfigManager) SetProfile(name string, profile config.Profile) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockClient ¶
MockClient is a mock implementation of the AhaSendClient interface
func (*MockClient) CancelMessage ¶
func (m *MockClient) CancelMessage(accountID, messageID string) (*common.SuccessResponse, error)
func (*MockClient) CheckSuppression ¶
func (m *MockClient) CheckSuppression(email string, domain *string) (bool, *responses.Suppression, error)
func (*MockClient) ConnectWebSocket ¶
func (m *MockClient) ConnectWebSocket(wsURL, webhookID string, forceReconnect, skipVerify bool) (*client.WebSocketClient, error)
func (*MockClient) CreateAPIKey ¶
func (m *MockClient) CreateAPIKey(req requests.CreateAPIKeyRequest) (*responses.APIKey, error)
func (*MockClient) CreateDomain ¶
func (m *MockClient) CreateDomain(domain string) (*responses.Domain, error)
func (*MockClient) CreateRoute ¶
func (m *MockClient) CreateRoute(req requests.CreateRouteRequest) (*responses.Route, error)
func (*MockClient) CreateSMTPCredential ¶
func (m *MockClient) CreateSMTPCredential(req requests.CreateSMTPCredentialRequest) (*responses.SMTPCredential, error)
func (*MockClient) CreateSuppression ¶
func (m *MockClient) CreateSuppression(req requests.CreateSuppressionRequest) (*responses.CreateSuppressionResponse, error)
func (*MockClient) CreateWebhook ¶
func (m *MockClient) CreateWebhook(req requests.CreateWebhookRequest) (*responses.Webhook, error)
func (*MockClient) CreateWebhookVerifier ¶
func (m *MockClient) CreateWebhookVerifier(secret string) (*webhooks.WebhookVerifier, error)
func (*MockClient) DeleteAPIKey ¶
func (m *MockClient) DeleteAPIKey(keyID string) (*common.SuccessResponse, error)
func (*MockClient) DeleteDomain ¶
func (m *MockClient) DeleteDomain(domain string) (*common.SuccessResponse, error)
func (*MockClient) DeleteRoute ¶
func (m *MockClient) DeleteRoute(routeID string) error
func (*MockClient) DeleteSMTPCredential ¶
func (m *MockClient) DeleteSMTPCredential(credentialID string) error
func (*MockClient) DeleteSuppression ¶
func (m *MockClient) DeleteSuppression(email string, domain *string) (*common.SuccessResponse, error)
func (*MockClient) DeleteWebhook ¶
func (m *MockClient) DeleteWebhook(webhookID string) error
func (*MockClient) GetAPIKey ¶
func (m *MockClient) GetAPIKey(keyID string) (*responses.APIKey, error)
func (*MockClient) GetAccount ¶
func (m *MockClient) GetAccount() (*responses.Account, error)
func (*MockClient) GetAccountID ¶
func (m *MockClient) GetAccountID() string
func (*MockClient) GetAuthContext ¶
func (m *MockClient) GetAuthContext() context.Context
func (*MockClient) GetBounceStatistics ¶
func (m *MockClient) GetBounceStatistics(params requests.GetBounceStatisticsParams) (*responses.BounceStatisticsResponse, error)
func (*MockClient) GetDeliverabilityStatistics ¶
func (m *MockClient) GetDeliverabilityStatistics(params requests.GetDeliverabilityStatisticsParams) (*responses.DeliverabilityStatisticsResponse, error)
Statistics operations methods
func (*MockClient) GetDeliveryTimeStatistics ¶
func (m *MockClient) GetDeliveryTimeStatistics(params requests.GetDeliveryTimeStatisticsParams) (*responses.DeliveryTimeStatisticsResponse, error)
func (*MockClient) GetDomain ¶
func (m *MockClient) GetDomain(domain string) (*responses.Domain, error)
func (*MockClient) GetMessages ¶
func (m *MockClient) GetMessages(params requests.GetMessagesParams) (*responses.PaginatedMessagesResponse, error)
func (*MockClient) GetRoute ¶
func (m *MockClient) GetRoute(routeID string) (*responses.Route, error)
func (*MockClient) GetSMTPCredential ¶
func (m *MockClient) GetSMTPCredential(credentialID string) (*responses.SMTPCredential, error)
func (*MockClient) GetWebhook ¶
func (m *MockClient) GetWebhook(webhookID string) (*responses.Webhook, error)
func (*MockClient) InitiateWebhookStream ¶
func (m *MockClient) InitiateWebhookStream(webhookID string) (*client.WebhookStreamResponse, error)
func (*MockClient) ListAPIKeys ¶
func (m *MockClient) ListAPIKeys(limit *int32, cursor *string) (*responses.PaginatedAPIKeysResponse, error)
API Key operations methods
func (*MockClient) ListDomains ¶
func (m *MockClient) ListDomains(limit *int32, cursor *string) (*responses.PaginatedDomainsResponse, error)
func (*MockClient) ListRoutes ¶
func (m *MockClient) ListRoutes(limit *int32, cursor *string) (*responses.PaginatedRoutesResponse, error)
func (*MockClient) ListSMTPCredentials ¶
func (m *MockClient) ListSMTPCredentials(limit *int32, cursor *string) (*responses.PaginatedSMTPCredentialsResponse, error)
func (*MockClient) ListSuppressions ¶
func (m *MockClient) ListSuppressions(params requests.GetSuppressionsParams) (*responses.PaginatedSuppressionsResponse, error)
func (*MockClient) ListWebhooks ¶
func (m *MockClient) ListWebhooks(limit *int32, cursor *string) (*responses.PaginatedWebhooksResponse, error)
func (*MockClient) NewMockDomain ¶
func (m *MockClient) NewMockDomain(domain string, valid bool) *responses.Domain
NewMockDomain creates a mock domain for testing
func (*MockClient) NewMockDomainsResponse ¶
func (m *MockClient) NewMockDomainsResponse(domains []responses.Domain, hasMore bool) *responses.PaginatedDomainsResponse
NewMockDomainsResponse creates a mock paginated domains response for testing
func (*MockClient) NewMockMessageResponse ¶
func (m *MockClient) NewMockMessageResponse(messageID string) *responses.CreateMessageResponse
NewMockMessageResponse creates a mock create message response for testing
func (*MockClient) NewMockMessagesResponse ¶
func (m *MockClient) NewMockMessagesResponse(messages []responses.Message, hasMore bool) *responses.PaginatedMessagesResponse
NewMockMessagesResponse creates a mock paginated messages response for testing
func (*MockClient) NewMockRoute ¶
func (m *MockClient) NewMockRoute(idStr, name, url, recipientFilter string, enabled bool) *responses.Route
NewMockRoute creates a mock route for testing
func (*MockClient) NewMockRouteWithOptions ¶
func (m *MockClient) NewMockRouteWithOptions(idStr, name, url string, enabled bool, options map[string]bool) *responses.Route
NewMockRouteWithOptions creates a mock route with processing options for testing
func (*MockClient) NewMockRoutesResponse ¶
func (m *MockClient) NewMockRoutesResponse(routes []responses.Route, hasMore bool) *responses.PaginatedRoutesResponse
NewMockRoutesResponse creates a mock paginated routes response for testing
func (*MockClient) NewMockSMTPCredential ¶
func (m *MockClient) NewMockSMTPCredential(id uint64, name, username, scope string, sandbox bool, domains []string) *responses.SMTPCredential
NewMockSMTPCredential creates a mock SMTP credential for testing
func (*MockClient) NewMockSMTPCredentialsResponse ¶
func (m *MockClient) NewMockSMTPCredentialsResponse(credentials []responses.SMTPCredential, hasMore bool) *responses.PaginatedSMTPCredentialsResponse
NewMockSMTPCredentialsResponse creates a mock paginated SMTP credentials response for testing
func (*MockClient) NewMockSuppression ¶
func (m *MockClient) NewMockSuppression(email, reason, domain string) *responses.Suppression
NewMockSuppression creates a mock suppression for testing
func (*MockClient) NewMockSuppressionWithExpiry ¶
func (m *MockClient) NewMockSuppressionWithExpiry(email, reason, domain string, expiresIn time.Duration) *responses.Suppression
NewMockSuppressionWithExpiry creates a mock suppression with expiry time for testing
func (*MockClient) NewMockSuppressionsResponse ¶
func (m *MockClient) NewMockSuppressionsResponse(suppressions []responses.Suppression, hasMore bool) *responses.PaginatedSuppressionsResponse
NewMockSuppressionsResponse creates a mock paginated suppressions response for testing
func (*MockClient) NewMockWebhook ¶
func (m *MockClient) NewMockWebhook(idStr, name, url string, enabled bool) responses.Webhook
NewMockWebhook creates a mock webhook for testing
func (*MockClient) NewMockWebhooksResponse ¶
func (m *MockClient) NewMockWebhooksResponse(webhooks []responses.Webhook, hasMore bool) *responses.PaginatedWebhooksResponse
NewMockWebhooksResponse creates a mock paginated webhooks response for testing
func (*MockClient) Ping ¶
func (m *MockClient) Ping() error
func (*MockClient) SendMessage ¶
func (m *MockClient) SendMessage(req requests.CreateMessageRequest) (*responses.CreateMessageResponse, error)
func (*MockClient) SendMessageWithIdempotencyKey ¶
func (m *MockClient) SendMessageWithIdempotencyKey(req requests.CreateMessageRequest, idempotencyKey string) (*responses.CreateMessageResponse, error)
func (*MockClient) TriggerWebhook ¶
func (m *MockClient) TriggerWebhook(webhookID string, events []string) error
func (*MockClient) UpdateAPIKey ¶
func (m *MockClient) UpdateAPIKey(keyID string, req requests.UpdateAPIKeyRequest) (*responses.APIKey, error)
func (*MockClient) UpdateRoute ¶
func (m *MockClient) UpdateRoute(routeID string, req requests.UpdateRouteRequest) (*responses.Route, error)
func (*MockClient) UpdateWebhook ¶
func (m *MockClient) UpdateWebhook(webhookID string, req requests.UpdateWebhookRequest) (*responses.Webhook, error)
func (*MockClient) ValidateConfiguration ¶
func (m *MockClient) ValidateConfiguration() error
func (*MockClient) WipeSuppressions ¶
func (m *MockClient) WipeSuppressions(domain *string) (*common.SuccessResponse, error)
type MockConfigManager ¶
MockConfigManager is a mock implementation of the ConfigManager interface
func (*MockConfigManager) GetConfig ¶
func (m *MockConfigManager) GetConfig() *config.Config
func (*MockConfigManager) GetCurrentProfile ¶
func (m *MockConfigManager) GetCurrentProfile() (*config.Profile, error)
func (*MockConfigManager) GetPreference ¶
func (m *MockConfigManager) GetPreference(key string) (string, error)
func (*MockConfigManager) ListProfiles ¶
func (m *MockConfigManager) ListProfiles() []string
func (*MockConfigManager) Load ¶
func (m *MockConfigManager) Load() error
func (*MockConfigManager) NewMockConfig ¶
func (m *MockConfigManager) NewMockConfig() *config.Config
NewMockConfig creates a mock config for testing
func (*MockConfigManager) NewMockProfile ¶
func (m *MockConfigManager) NewMockProfile(name, apiKey, accountID string) config.Profile
NewMockProfile creates a mock profile for testing
func (*MockConfigManager) RemoveProfile ¶
func (m *MockConfigManager) RemoveProfile(name string) error
func (*MockConfigManager) Save ¶
func (m *MockConfigManager) Save() error
func (*MockConfigManager) SetDefaultProfile ¶
func (m *MockConfigManager) SetDefaultProfile(name string) error
func (*MockConfigManager) SetPreference ¶
func (m *MockConfigManager) SetPreference(key, value string) error
func (*MockConfigManager) SetProfile ¶
func (m *MockConfigManager) SetProfile(name string, profile config.Profile) error