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 ¶
- Variables
- func DynamoDB() (*dynamodb.Client, error)
- func GSI(i string, h AttributeDefinition, s AttributeDefinition, ...) dynamodb.GlobalSecondaryIndex
- func LSI(i string, h AttributeDefinition, s AttributeDefinition, ...) dynamodb.LocalSecondaryIndex
- func MakeNewTable(db *dynamodb.Client, tableName string, attrs Attributes, keys Keys, ...) error
- func MakeTestTable(db *dynamodb.Client) (*string, error)
- func PutItem(db *dynamodb.Client, tableName string, item interface{}) (*dynamodb.PutItemResponse, error)
- type AttributeDefinition
- type Attributes
- type GlobalSecondaryIndexes
- type Keys
- type LocalSecondaryIndexes
- type SortKeyTestCase
- type TestDynamoItem
Constants ¶
This section is empty.
Variables ¶
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 }
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) }
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) }
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 GSI ¶
func GSI(i string, h AttributeDefinition, s AttributeDefinition, p dynamodb.ProjectionType, t *dynamodb.ProvisionedThroughput, nonKeyAttrs []string) dynamodb.GlobalSecondaryIndex
GSI is a factory function for creating a dynamodb.GlobalSecondaryIndex
func LSI ¶
func LSI(i string, h AttributeDefinition, s AttributeDefinition, p dynamodb.ProjectionType, nonKeyAttrs []string) dynamodb.LocalSecondaryIndex
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
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 ¶
func (a AttributeDefinition) KeyElement(k dynamodb.KeyType) dynamodb.KeySchemaElement
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 ¶
type Keys []dynamodb.KeySchemaElement
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)