Skip to content

Commit 32ef68d

Browse files
author
Robert Bradley
committed
Adding nightly testing
1 parent 1b24dd8 commit 32ef68d

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535
- name: Start DynamoDB Local
3636
run: docker run -d -p 8000:8000 amazon/dynamodb-local
3737

38+
- name: Create Rooms table for testing
39+
run: node scripts/create-local-table.js
40+
3841
- name: Set up env vars
3942
run: |
4043
echo "AWS_ACCESS_KEY_ID=FAKE_KEY" >> $GITHUB_ENV
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// scripts/create-local-table.js
2+
// This is used to create a test table in our local copy of DynamoDB when the tests run
3+
// This is not used if deploying infrastructure to AWS
4+
const { DynamoDBClient, CreateTableCommand } = require('@aws-sdk/client-dynamodb');
5+
6+
(async () => {
7+
try {
8+
const client = new DynamoDBClient({
9+
region: process.env.AWS_REGION || "us-west-2",
10+
endpoint: process.env.DYNAMODB_ENDPOINT || "http://localhost:8000",
11+
credentials: {
12+
accessKeyId: process.env.AWS_ACCESS_KEY_ID || "FAKE_KEY",
13+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || "FAKE_SECRET",
14+
},
15+
});
16+
17+
const tableName = process.env.DYNAMODB_TABLE_NAME || "RoomsTest";
18+
19+
const command = new CreateTableCommand({
20+
TableName: tableName,
21+
AttributeDefinitions: [
22+
{ AttributeName: 'id', AttributeType: 'N' },
23+
],
24+
KeySchema: [
25+
{ AttributeName: 'id', KeyType: 'HASH' },
26+
],
27+
ProvisionedThroughput: {
28+
ReadCapacityUnits: 5,
29+
WriteCapacityUnits: 5,
30+
},
31+
SSESpecification: {
32+
Enabled: true, // server-side encryption
33+
},
34+
});
35+
36+
const result = await client.send(command);
37+
console.log(`Created table '${tableName}' locally.`, result.TableDescription?.TableStatus);
38+
} catch (err) {
39+
console.error('Error creating table locally:', err);
40+
process.exit(1);
41+
}
42+
})();

0 commit comments

Comments
 (0)