modulepackage
0.0.0-20230607084046-6c6029b9b3f9
Repository: https://github.com/prozz/snstesting.git
Documentation: pkg.go.dev
# README
snstesting
Package snstesting
simplifies checking what messages arrive at any SNS topic from the inside of your integration tests.
It does it by subscribing to SNS via ad-hoc SQS queue that is cleaned-up after the test.
Installation
go get github.com/prozz/snstesting
Usage
// make sure you can access AWS
cfg, err := config.LoadDefaultConfig(ctx)
if err != nil {
t.Fatalf("configuration error: %v ", err)
}
// subscribe to SNS, all resources created here will be cleaned up at the end of the test
receive := snstesting.New(t, cfg, topicName)
// fire your process here, whatever it is ;)
// get single message from SNS and examine it, repeat if needed
msg := receive()
assert.NotEmpty(t, msg)
In case you need more control over error handling, context or long polling settings, please use snstesting.NewSubscriber
directly.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests.
License
# Packages
Package mock is a generated GoMock package.
# Functions
New creates Subscriber for testing purposes based on provided AWS configuration.
NewSubscriber creates Subscriber instance for ad-hoc subscribing to SNS topic.
# Structs
Config describes both temporarily generated and existing resources used by the ad-hoc SNS checking mechanism.
Subscriber for checking what arrives at any SNS topic in an integration testing setting.
# Type aliases
ReceiveFn checks for message that arrived at SNS (via ad-hoc SQS queue), can be called repeatedly.