Skip to content
This repository has been archived by the owner on Mar 5, 2018. It is now read-only.

rosenhouse/awsfaker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

awsfaker

Build Status GoDoc

A Go library for faking AWS over the network

Quick start

Check out the example

Context

Integration testing of applications that use AWS can be difficult. A test suite that interacts with a live AWS account will provide good test coverage, but may be slow and expensive.

An alternative is to create a test double or "fake" of the AWS APIs that your application uses. The fake boots an HTTP server that stands in for the real AWS endpoints, recording requests and providing arbitrary responses.

This package provides a generic HTTP handler that can form the front-end of a test double (mock, fake or stub) for an AWS API.

Usage

  1. Build a "backend" that implements the subset of the AWS API used by your code.

Each API call should be implemented as a backend method with a signature like

func (b *MyBackend) SomeAction(input *service.SomeActionInput) (*service.SomeActionOutput, error)
  1. During test setup, initialize an HTTP test server that wraps your backend
myBackend := &MyBackend{ ... }
fakeServer := httptest.NewServer(awsfaker.New(myBackend))
  1. In your tests, configure the client that you are testing to use your fake server instead of the real AWS
app := myapp.App{ AWSOverride: fakeServer.URL }
app.Run()

The method signatures expected on the backends match the patterns of aws-sdk-go. For example, a complete implementation of AWS CloudFormation would match the CloudFormationAPI interface

But your backend need only implement those methods used by your code under test.

API Support

Should work

  • ec2query: ec2

  • query: autoscaling, cloudformation, cloudsearch, cloudwatch, elasticache, elasticbeanstalk, elb, iam, rds, redshift, ses, simpledb, sns, sqs, sts

Not yet implemented

  • jsonrpc: cloudhsm, cloudtrail, cloudwatchlogs, codecommit, codedeploy, codepipeline, cognitoidentity, configservice, datapipeline, devicefarm, directconnect, directoryservice, dynamodb, dynamodbstreams, ecs, emr, firehose, inspector, kinesis, kms, machinelearning, marketplacecommerceanalytics, opsworks, route53domains, ssm, storagegateway, support, swf, waf, workspaces

  • restjson: apigateway, cloudsearchdomain, cognitosync, efs, elasticsearchservice, elastictranscoder, glacier, iot, iotdataplane, lambda, mobileanalytics

  • restxml: cloudfront, route53, s3

About

A Go library for faking AWS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages