DynamoDB
Seed DynamoDB tables and check the items your services write.
The steps use the scenario’s AWS account (the {word} aws account with the following properties:, from aws-core).
A seed is a YAML or JSON file that maps table names to the items to put, written as plain JSON (numbers become N, objects M, arrays L):
insured-parcels: - reference: PX-CLM-1001 declaredValue: 120 carrier: KESTRELChecks wait (10 seconds unless within {duration} says otherwise) until the table has an item, or a number of items, meeting every condition: attribute | value rows with a dotted path into maps (address.city), compared as text, null for null and undefined for absent. Items are read with a scan, which suits the small tables of a test environment.
Add it to a project with axx pack add aws-dynamodb; it builds on aws-core, which comes with it.
aws-dynamodb.seed
Section titled “aws-dynamodb.seed”Given a {filepath} dynamodb seedPut the items of a seed file into their tables: YAML or JSON that maps table names to lists of items. Items are plain JSON: numbers become N, objects M and arrays L.
| Parameter | Takes | For example |
|---|---|---|
{filepath} |
a file of the project: a path relative to the feature file’s directory, the resources directories or axx.yaml’s directory (looked for in that order), or an absolute path, quoted when it has a space |
seeds/parcels.yaml, kafka/scan-delivered.json |
Example:
Given a seeds/insured-parcels.yaml dynamodb seedSince 0.1.0.
aws-dynamodb.item
Section titled “aws-dynamodb.item”Then [[within {duration} ]]the {word} dynamodb table has an item where: | attribute | value |The table may start with the row naming its columns, as above, or go straight to its rows.
Check that the table has an item with those values in those attributes. The check waits for it: 10 seconds, or within {duration}.
| Parameter | Takes | For example |
|---|---|---|
{duration} |
a duration in seconds (s) or minutes (m) |
5s, 2m |
{word} |
one word, with no spaces | parcels, PX-4101 |
Each row names an attribute of the item, or a dotted path into a map (address.city), and the value it has, compared as text: null for null and undefined for absent. Sets read as lists, and binary as base64.
Variants, the parts in [[...]] said or left out:
the {word} dynamodb table has an item where:within {duration} the {word} dynamodb table has an item where:
Example:
Then within 30s the claims dynamodb table has an item where: | id | CLM-4101 | | status | APPROVED | | amount | 89.5 |Since 0.1.0.
aws-dynamodb.items
Section titled “aws-dynamodb.items”Then [[within {duration} ]]the {word} dynamodb table has {int} item(s) where: | attribute | value |The table may start with the row naming its columns, as above, or go straight to its rows.
Check that exactly that many items of the table have those values in those attributes. The check waits for it: 10 seconds, or within {duration}.
| Parameter | Takes | For example |
|---|---|---|
{duration} |
a duration in seconds (s) or minutes (m) |
5s, 2m |
{word} |
one word, with no spaces | parcels, PX-4101 |
{int} |
a whole number | 200, 3 |
Each row names an attribute of the item, or a dotted path into a map (address.city), and the value it has, compared as text: null for null and undefined for absent. Sets read as lists, and binary as base64.
Variants, the parts in [[...]] said or left out:
the {word} dynamodb table has {int} item(s) where:within {duration} the {word} dynamodb table has {int} item(s) where:
Example:
Then the claims dynamodb table has 1 item where: | parcel | PX-4107 |Since 0.1.0.