Skip to content

ebh/mocksqs

 
 

Repository files navigation

📤 github.com/elliotchance/mocksqs

Build Status GoDoc

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():

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.

Events

Functions can be set on queues to help with unit testing life cycle. For example:

client.GetQueue(url).OnEmptyQueue = func() {
	// Clean up, assert, cancel context, etc.
}

See the documentation for 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:

client.SimulateHTTPLatency = true

About

📤 In-memory implementation of SQS ideal for unit testing.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%