Categorygithub.com/wepala/go-testhelpers
modulepackage
0.0.0-20200715110105-55c57c235b75
Repository: https://github.com/wepala/go-testhelpers.git
Documentation: pkg.go.dev

# README

go-testhelpers

Series of functions for testing in go

AWS Helpers

These helpers are for mocking services provided by the AWS go SDK. While the SDK does describe how to mock the services it's very inconvenient to do so consistently

Dynamodb Helpers

mockedDbFunctions := make(map[string]interface{})
mockedDbFunctions["UpdateItem"] = testhelpers.UpdateItemFunc(func(input *dynamodb.UpdateItemInput) (*dynamodb.UpdateItemOutput, error) {

    key1 := input.Key["key1"]
    if *key1.S != "value1" {
        t.Errorf("Expected token to be 'value1', got '%s'", *key1.S)
    }
    return &dynamodb.UpdateItemOutput{}, nil
})
mockClient := testhelpers.NewMockDynamoDBClient(mockedDbFunctions)

# Functions

No description provided by the author
No description provided by the author
NewBytesResponse creates an *http.Response with a body based on the given bytes.
This is meant to make it easy to record request and responses so that they can be used later as test fixtures.
NewJsonResponse creates an *http.Response with a body that is a json encoded representation of the given interface{}.
NewMockDynamoDBClient creates a new mock dynamo db clientexamplemockedDbFunctions := make(map[string]interface{})mockedDbFunctions["UpdateItem"] = testhelpers.DynamoDBUpdateItem(func(input *dynamodb.UpdateItemInput) (*dynamodb.UpdateItemOutput, error) { return &dynamodb.UpdateItemOutput{}, nil})mockedDbFunctions["Query"] = testhelpers.DynamoDBQuery(func(input *dynamodb.QueryInput) (*dynamodb.QueryOutput, error) { return &dynamodb.QueryOutput{}, nil}).
NewRespBodyFromBytes creates an io.ReadCloser from a byte slice that is suitable for use as an http response body.
NewRespBodyFromString creates an io.ReadCloser from a string that is suitable for use as an http response body.
NewStringResponse creates an *http.Response with a body based on the given string.
NewTestClient returns *http.Client with Transport replaced to avoid making real calls.
NewXmlResponse creates an *http.Response with a body that is an xml encoded representation of the given interface{}.

# Structs

MockDynamoDBClient provides a mock implementation of DynamoDBAPI To use this client you specify the function you would like to override by appending 'Func' to the original method name (e.g.

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
RoundTripFunc .