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, p types.ProjectionType, ...) types.GlobalSecondaryIndex
- func LSI(i string, h AttributeDefinition, s AttributeDefinition, p types.ProjectionType, ...) types.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.PutItemOutput, 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 types.ProjectionType, t *types.ProvisionedThroughput, nonKeyAttrs []string) types.GlobalSecondaryIndex
GSI is a factory function for creating a types.GlobalSecondaryIndex
func LSI ¶
func LSI(i string, h AttributeDefinition, s AttributeDefinition, p types.ProjectionType, nonKeyAttrs []string) types.LocalSecondaryIndex
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
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 ¶
func (a AttributeDefinition) KeyElement(k types.KeyType) types.KeySchemaElement
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)