Last active
September 13, 2021 13:01
-
-
Save ericdmoore/39c3d02ed8a4aca3afce8120654f7183 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* using ts-jest */ | |
import { DynamoDB } from 'aws-sdk' | |
import localDynamo from 'local-dynamo' | |
import { appTable, click } from '../src/entities' | |
let dynamoLocal: ChildProcess | |
beforeAll(async () => { | |
// start local Dynamo Svc | |
// and set the internals of the Entity framework to use the locally configured reader/writer | |
dynamoLocal = await localDynamo.launch(undefined, 4567) | |
const dyn = new DynamoDB({ region: 'us-east-1', endpoint: 'http://localhost:4567' }) | |
const localDC = new DynamoDB.DocumentClient({ service: dyn }) | |
// mutate the appTable to use local Service and DC | |
appTable.DocumentClient = localDC | |
click.ent.table.DocumentClient = localDC | |
const dyn = new DynamoDB({ region: 'us-east-1', endpoint: 'http://localhost:4567' }) | |
await dyn.createTable({ | |
TableName: 'myTableName', | |
AttributeDefinitions: [ | |
{ AttributeName: 'pk', AttributeType: 'S' }, | |
{ AttributeName: 'sk', AttributeType: 'S' } | |
], | |
KeySchema: [ | |
{ AttributeName: 'pk', KeyType: 'HASH' }, | |
{ AttributeName: 'sk', KeyType: 'RANGE' } | |
], | |
BillingMode: 'PAY_PER_REQUEST', | |
ProvisionedThroughput: { | |
ReadCapacityUnits: 5, | |
WriteCapacityUnits: 5 | |
} | |
}).promise() | |
await generateDataNeededForTests() | |
}, 45 * 1000) | |
afterAll(() => dynamoLocal.kill('SIGTERM')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this will work for most people following the opinions laid out in the single-table design....