Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elliotchance/mocksqs
📤 In-memory implementation of SQS ideal for unit testing.
https://github.com/elliotchance/mocksqs
aws mock sqs unit-testing
Last synced: about 1 month ago
JSON representation
📤 In-memory implementation of SQS ideal for unit testing.
- Host: GitHub
- URL: https://github.com/elliotchance/mocksqs
- Owner: elliotchance
- License: mit
- Created: 2019-12-11T11:01:37.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-08T14:27:05.000Z (5 months ago)
- Last Synced: 2024-10-09T11:36:18.229Z (about 1 month ago)
- Topics: aws, mock, sqs, unit-testing
- Language: Go
- Homepage:
- Size: 26.4 KB
- Stars: 13
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 📤 github.com/elliotchance/mocksqs
[![Build Status](https://travis-ci.org/elliotchance/mocksqs.svg?branch=master)](https://travis-ci.org/elliotchance/mocksqs)
[![GoDoc](https://godoc.org/github.com/elliotchance/mocksqs?status.svg)](https://godoc.org/github.com/elliotchance/mocksqs)# Creating the Service
The simplest way to create a new SQS service is with `mocksqs.New()`. However,
if you need queues prepopulated you can use `mocksqs.NewWithQueues()`:```go
url := "https://sqs.us-east-1.amazonaws.com/281910179584/mocksqs"
client := mocksqs.NewWithQueues(map[string][]string{
url: {"foo", "bar"},
})result, err := client.ReceiveMessage(&sqs.ReceiveMessageInput{
QueueUrl: aws.String(url),
})
```# Supported Functionality
Only some of the common SQS methods are implemented. Methods not implemented
will panic.You can view the specific implementation details in the
[godoc documentation](https://godoc.org/github.com/elliotchance/mocksqs).# Events
Functions can be set on queues to help with unit testing life cycle. For
example:```go
client.GetQueue(url).OnEmptyQueue = func() {
// Clean up, assert, cancel context, etc.
}
```See the
[documentation for Queue](https://godoc.org/github.com/elliotchance/mocksqs#Queue)
for more information.# Simulating HTTP Latency
SimulateHTTPLatency when enabled will add a sleep between 20 and 100
milliseconds to each call that would otherwise need to make a HTTP request with
a real SQS client:```go
client.SimulateHTTPLatency = true
```