Amazon DynamoDB testing library written in Go.
- Make local testing for DynamoDB as accurate as possible.
- Run DynamoDB tests in a CI without external dependencies.
- Identify errors caused by DynamoDB restrictions.
Create the dynamodb client:
client := minidyn.NewClient()
Define the tables and indexes schemas,you can use the SDKs methods to create tables.
client.CreateTable(&dynamodb.CreateTableInput{
TableName: aws.String("pokemons"),
AttributeDefinitions: []*dynamodb.AttributeDefinition{
{
AttributeName: aws.String("id"),
AttributeType: aws.String("S"),
},
},
BillingMode: aws.String("PAY_PER_REQUEST"),
KeySchema: []*dynamodb.KeySchemaElement{
{
AttributeName: aws.String("id"),
KeyType: aws.String("HASH"),
},
},
})
Or you can use the AddTable and AddIndex method helper.
err := client.AddTable("pokemons", "id", "primary_type")
if err != nil {
return err
}
err = client.AddIndex("pokemons", "type_index", "primary_type", "")
if err != nil {
return err
}
NOTE these methods only support string attributes.
This library has an interpreter implementation for the DynamoDB Expressions.
Name | Type | Short | Supported? |
---|---|---|---|
Number | scalar | N | y |
String | scalar | S | y |
Binary | scalar | B | y |
Bool | scalar | BOOL | y |
Null | scalar | NULL | y |
List | document | L | y |
Map | document | M | y |
StringSet | set | SS | y |
NumberSet | set | NS | y |
BinarySet | set | BS | y |
Syntax | Supported? | |
---|---|---|
operand comparator operand | = <> < <= > and >= | y |
operand BETWEEN operand AND operand | N,S,B | y |
operand IN ( operand (',' operand (, ...) )) | y | |
function | attribute_exists, attribute_not_exists, attribute_type, begins_with, contains, size | y |
condition AND condition | y | |
condition OR condition | y | |
NOT condition | y |
Syntax | Supported? | |
---|---|---|
SET | SET action [, action] ... | y |
REMOVE | REMOVE action [, action] ... | y |
ADD | ADD action [, action] ... | y |
DELETE | DELETE action [, action] ... | y |
function | list_append, if_not_exists | y |
When it happens you can override the intepretation using like this:
client.ActivateNativeInterpreter()
client.GetNativeInterpreter().AddUpdater(table, "SET secondary_type = :secondary_type", func(item map[string]*dynamodb.AttributeValue, updates map[string]*dynamodb.AttributeValue) {
item["secondary_type"] = updates[":secondary_type"]
})
Note: Please, report us the issue with the interpreter through https://github.com/truora/minidyn/issues
The MIT License