testutils

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: Apache-2.0 Imports: 9 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 types.GlobalSecondaryIndex

func LSI

LSI is a factory function for creating a types.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.PutItemOutput, error)

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

Types

type AttributeDefinition

type AttributeDefinition types.AttributeDefinition

AttributeDefinition is a type alias for types.AttributeDefinition

func MakeAttribute

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

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

func (AttributeDefinition) AttributeDefinition

func (a AttributeDefinition) AttributeDefinition() types.AttributeDefinition

AttributeDefinition returns a dynamocity.AttributeDefinition as a types.AttributeDefinition

func (AttributeDefinition) KeyElement

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

type Attributes

type Attributes []types.AttributeDefinition

Attributes type alias for a slice of types.AttributeDefinition

type GlobalSecondaryIndexes

type GlobalSecondaryIndexes []types.GlobalSecondaryIndex

GlobalSecondaryIndexes type alias for a slice of types.GlobalSecondaryIndex

type Keys

type Keys []types.KeySchemaElement

Keys type alias for a slice of types.KeySchemaElement

type LocalSecondaryIndexes

type LocalSecondaryIndexes []types.LocalSecondaryIndex

LocalSecondaryIndexes type alias for a slice of types.LocalSecondaryIndex

type SortKeyTestCase

type SortKeyTestCase struct {
	Name       string
	Timestamp  string
	SortKey    string
	IndexName  string
	KeyBuilder func(SortKeyTestCase, *testing.T) interface{}
	Verify     func([]map[string]types.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