testutils

package
v0.0.1-alpha-5 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package testutils provides utility types for supporting testing time.

aws_api_types.go supplies a number of utility functions specifically for scaffolding a test database.

Index

Constants

This section is empty.

Variables

View Source
var GoTimeKeyBuilder = func(tc SortKeyTestCase, t *testing.T) interface{} {
	timestamp, err := time.Parse(time.RFC3339Nano, tc.Timestamp)
	if err != nil {
		t.Error(err)
		t.FailNow()
	}
	return timestamp
}
View Source
var MillisTimeKeyBuilder = func(tc SortKeyTestCase, t *testing.T) interface{} {
	timestamp, err := time.Parse(time.RFC3339Nano, tc.Timestamp)
	if err != nil {
		t.Error(err)
		t.FailNow()
	}
	return dynamocity.MillisTime(timestamp)
}
View Source
var NanoTimeKeyBuilder = func(tc SortKeyTestCase, t *testing.T) interface{} {
	timestamp, err := time.Parse(time.RFC3339Nano, tc.Timestamp)
	if err != nil {
		t.Error(err)
		t.FailNow()
	}
	return dynamocity.NanoTime(timestamp)
}
View Source
var SecondsTimeKeyBuilder = func(tc SortKeyTestCase, t *testing.T) interface{} {
	timestamp, err := time.Parse(time.RFC3339Nano, tc.Timestamp)
	if err != nil {
		t.Error(err)
		t.FailNow()
	}
	return dynamocity.SecondsTime(timestamp)
}

Functions

func DynamoDB

func DynamoDB() (*dynamodb.Client, error)

func GSI

GSI is a factory function for creating a dynamodb.GlobalSecondaryIndex

func LSI

LSI is a factory function for creating a dynamodb.LocalSecondaryIndex

func MakeNewTable

func MakeNewTable(db *dynamodb.Client, tableName string, attrs Attributes, keys Keys, gsis GlobalSecondaryIndexes, lsis LocalSecondaryIndexes) error

func MakeTestTable

func MakeTestTable(db *dynamodb.Client) (*string, error)

func PutItem

func PutItem(db *dynamodb.Client, tableName string, item interface{}) (*dynamodb.PutItemResponse, error)

PutItem is a utility function to put an item in the specified table using the provided *dynamodb.Client

Types

type AttributeDefinition

type AttributeDefinition dynamodb.AttributeDefinition

AttributeDefinition is a type alias for dynamodb.AttributeDefinition

func MakeAttribute

func MakeAttribute(attributeName string, attributeType dynamodb.ScalarAttributeType) *AttributeDefinition

MakeAttribute is a factory function for creating an AttributeDefinition for the specified attribute type

func (AttributeDefinition) AttributeDefinition

func (a AttributeDefinition) AttributeDefinition() dynamodb.AttributeDefinition

AttributeDefinition returns a dynamocity.AttributeDefinition as a dynamodb.AttributeDefinition

func (AttributeDefinition) KeyElement

KeyElement will return a dynamodb.KeySchemaElement of the specified dynamodb.KeyType for the given AttributeDefinition

type Attributes

type Attributes []dynamodb.AttributeDefinition

Attributes type alias for a slice of dynamodb.AttributeDefinition

type GlobalSecondaryIndexes

type GlobalSecondaryIndexes []dynamodb.GlobalSecondaryIndex

GlobalSecondaryIndexes type alias for a slice of dynamodb.GlobalSecondaryIndex

type Keys

Keys type alias for a slice of dynamodb.KeySchemaElement

type LocalSecondaryIndexes

type LocalSecondaryIndexes []dynamodb.LocalSecondaryIndex

LocalSecondaryIndexes type alias for a slice of dynamodb.LocalSecondaryIndex

type SortKeyTestCase

type SortKeyTestCase struct {
	Name       string
	Timestamp  string
	SortKey    string
	IndexName  string
	KeyBuilder func(SortKeyTestCase, *testing.T) interface{}
	Verify     func([]map[string]dynamodb.AttributeValue, SortKeyTestCase, *testing.T)
}

type TestDynamoItem

type TestDynamoItem struct {
	PartitionKey string                 `dynamodbav:"pk"`
	SortKey      string                 `dynamodbav:"sk"`
	GoTime       time.Time              `dynamodbav:"goTime"`
	NanoTime     dynamocity.NanoTime    `dynamodbav:"nanoTime"`
	MillisTime   dynamocity.MillisTime  `dynamodbav:"millisTime"`
	SecondsTime  dynamocity.SecondsTime `dynamodbav:"secondsTime"`
	StringTime   string                 `dynamodbav:"timestamp"`
}

func SetupTestFixtures

func SetupTestFixtures() (*dynamodb.Client, *string, []TestDynamoItem, error)

Jump to

Keyboard shortcuts

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