Mock request dispatcher and credentials for unit testing rusoto AWS service clients
All rusoto generated service clients come with a constuctor function named new_with
which
accepts three arguments
- A
rusoto_core::DispatchSignedRequest
implementation - A
rusoto_core::credential::ProvideAwsCredentials
implementation - A
rusoto_core::Region
This crate provides mock implementations to satisfy the first two.
Example
The following is an example for the rusoto_s3
crate but should
work for all service crates just the same. The code is commented
out for illustration but also to avoid a cyclic dependency in this crate.
extern crate rusoto_mock;
// extern crate rusoto_s3;
use ;
Note regarding XML-based AWS Services
Some AWS services such as SQS and STS return responses in XML format rather than JSON.
In these cases, parsing may fail with ParseError("Expected StartElement got None")
.
Valid XML examples can be found in the API documentation for an API call such as this one for STS AssumeRole.
These can be used to create a MockRequestDispatcher
like so:
.with_body
default