dynamem

package module
v0.0.0-...-25be07c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2021 License: MIT Imports: 7 Imported by: 0

README

DynaMem

A memory backed DynamoDB mock for unit tests

DynaMem simulates DynamoDB behaviour and is only designed to be used in unit tests.

DO NOT USE IN PRODUCTION

DynaMem is a work in progress. It is not feature complete (yet).

Usage

datastore.go

package myPackage

import (
    "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface"
)

type DataStore struct {
    client dynamodbiface.DynamoDBAPI
}

func NewDataStore(c dynamodbiface.DynamoDBAPI) *DataStore {
    return &DataStore{ client: c }
}

func (ds *DataStore) DoThings() {
    ds.client.PutItemWithContext(...)
}

func main() {
    dbClient := dynamodb.New(...)

    ds := NewDataStore(dbClient)
    ds.DoThings()
}

datastore_test.go

package myPackage

import (
        "github.com/danny-cheung/dynamem"
)

func datastore_doThings_test(t *testing.T) {
    mockClient := dynamem.New()

    ds := NewDataStore(mockClient)
    ds.DoThings()
}

Contributions

Feel free to create issues and pull requests.

All pull requests should be linked to an issue.

License

The MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynaMem

type DynaMem struct {
	dynamodbiface.DynamoDBAPI
	// contains filtered or unexported fields
}

func New

func New() *DynaMem

func (*DynaMem) CreateTable

func (dm *DynaMem) CreateTable(input *dynamodb.CreateTableInput) (*dynamodb.CreateTableOutput, error)

func (*DynaMem) CreateTableWithContext

func (dm *DynaMem) CreateTableWithContext(ctx aws.Context, input *dynamodb.CreateTableInput, opts ...request.Option) (*dynamodb.CreateTableOutput, error)

func (*DynaMem) DeleteItem

func (dm *DynaMem) DeleteItem(input *dynamodb.DeleteItemInput) (*dynamodb.DeleteItemOutput, error)

func (*DynaMem) DeleteItemWithContext

func (dm *DynaMem) DeleteItemWithContext(ctx aws.Context, input *dynamodb.DeleteItemInput, opts ...request.Option) (*dynamodb.DeleteItemOutput, error)

func (*DynaMem) GetItem

func (dm *DynaMem) GetItem(input *dynamodb.GetItemInput) (*dynamodb.GetItemOutput, error)

func (*DynaMem) GetItemWithContext

func (dm *DynaMem) GetItemWithContext(ctx aws.Context, input *dynamodb.GetItemInput, opts ...request.Option) (*dynamodb.GetItemOutput, error)

func (*DynaMem) PutItem

func (dm *DynaMem) PutItem(input *dynamodb.PutItemInput) (*dynamodb.PutItemOutput, error)

func (*DynaMem) PutItemWithContext

func (dm *DynaMem) PutItemWithContext(ctx aws.Context, input *dynamodb.PutItemInput, opts ...request.Option) (*dynamodb.PutItemOutput, error)

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL