Skip to content

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

License

Notifications You must be signed in to change notification settings

elliotchance/mocksqs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages