[][src]Crate rusoto_mock

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 rusoto_mock::{MockCredentialsProvider, MockRequestDispatcher, MockResponseReader};

fn main() {
   // let s3 = rusoto_s3::S3Client::new_with(
   //   MockRequestDispatcher::default().with_body(
   //      MockResponseReader::read_response("test-data", "s3-response.json")
   //   ),
   //   MockCredentialsProvider,
   //   Default::default()
   // );
}

Structs

MockCredentialsProvider

Provides a set of credentials that always resolve successfully

MockRequestDispatcher

Composes mock API responses

MockResponseReader

Reads response body content from disk

MultipleMockRequestDispatcher

Returns sequential mock API responses consuming a collection of MockRequestDispatch

Traits

ReadMockResponse

An interface for producing response body content