https://github.com/prozz/snstesting
Package snstesting simplifies checking what messages arrive at any SNS topic from the inside of your integration tests.
https://github.com/prozz/snstesting
Last synced: 5 months ago
JSON representation
Package snstesting simplifies checking what messages arrive at any SNS topic from the inside of your integration tests.
- Host: GitHub
- URL: https://github.com/prozz/snstesting
- Owner: prozz
- License: mit
- Created: 2022-04-08T10:53:07.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-08-28T11:49:26.000Z (almost 3 years ago)
- Last Synced: 2024-06-20T00:33:04.968Z (almost 2 years ago)
- Language: Go
- Size: 49.8 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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
```shell
go get github.com/prozz/snstesting
```
## Usage
```go
// 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
[MIT](https://choosealicense.com/licenses/mit/)