Documentation ¶
Overview ¶
Package snstesting simplifies checking what messages arrive at any SNS topic from the inside of your integration tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { TopicName string TopicARN string QueueName string QueueURL string QueueARN string SubscriptionARN string }
Config describes both temporarily generated and existing resources used by the ad-hoc SNS checking mechanism.
type ReceiveFn ¶
type ReceiveFn func() string
ReceiveFn checks for message that arrived at SNS (via ad-hoc SQS queue), can be called repeatedly.
func New ¶
New creates Subscriber for testing purposes based on provided AWS configuration. Ad-hoc resources are cleaned up after the test automatically with use of t.Cleanup. In case of an error, t.Fatal is executed. In case more control is needed over Subscriber, or it's Config, please use NewSubscriber.
type SNSAPI ¶
type SNSAPI interface { ListTopics(context.Context, *sns.ListTopicsInput, ...func(*sns.Options)) (*sns.ListTopicsOutput, error) Subscribe(context.Context, *sns.SubscribeInput, ...func(*sns.Options)) (*sns.SubscribeOutput, error) Unsubscribe(context.Context, *sns.UnsubscribeInput, ...func(*sns.Options)) (*sns.UnsubscribeOutput, error) }
SNSAPI shows part of SNS API needed to fulfill the contract.
type SQSAPI ¶
type SQSAPI interface { CreateQueue(context.Context, *sqs.CreateQueueInput, ...func(*sqs.Options)) (*sqs.CreateQueueOutput, error) DeleteQueue(context.Context, *sqs.DeleteQueueInput, ...func(*sqs.Options)) (*sqs.DeleteQueueOutput, error) GetQueueAttributes(context.Context, *sqs.GetQueueAttributesInput, ...func(*sqs.Options)) (*sqs.GetQueueAttributesOutput, error) //nolint SetQueueAttributes(context.Context, *sqs.SetQueueAttributesInput, ...func(*sqs.Options)) (*sqs.SetQueueAttributesOutput, error) //nolint ReceiveMessage(context.Context, *sqs.ReceiveMessageInput, ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error) }
SQSAPI shows part of SQS API needed to fulfill the contract.
type Subscriber ¶
Subscriber for checking what arrives at any SNS topic in an integration testing setting. It does it through temporary SQS queue and ad-hoc subscription that may be easily cleaned up after the test. Temporary queues are prefixed with 'snstesting'.
func NewSubscriber ¶
func NewSubscriber(ctx context.Context, SNS SNSAPI, SQS SQSAPI, topicName string) (Subscriber, error)
NewSubscriber creates Subscriber instance for ad-hoc subscribing to SNS topic.