Skip to content

Commit

Permalink
Automate the use of DynamoDB
Browse files Browse the repository at this point in the history
  • Loading branch information
daemonsy committed Jun 29, 2017
1 parent 7b64891 commit 1b4a48d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
node_modules
subway.zip
.env*
.env
downloads
.vscode
16 changes: 5 additions & 11 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
machine:
pre:
- mkdir -p ~/downloads
- mkdir -p ~/dynamodb_local
- wget -N https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz -P ~/downloads

post:
- tar -xvf /home/ubuntu/downloads/dynamodb_local_latest.tar.gz -C ~/dynamodb_local
- 'cd dynamodb_local;java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb':
background: true

node:
version: $NODE_RUNTIME_VERSION
environment:
Expand All @@ -30,14 +20,18 @@ dependencies:
else
echo "The correct version of Yarn is already installed."
fi
- yarn run dynamodb:download
- yarn run dynamodb:start:
background: true

override:
- yarn install


cache_directories:
- ~/.yarn
- ~/.cache/yarn
- ~/downloads
- ~/nyc-subway/downloads

test:
override:
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"main": "index.js",
"author": "Damon Aw <[email protected]>",
"scripts": {
"release": "rm -f subway.zip && yarn --production && zip -r subway.zip . -x *.git*",
"dynamodb:download": "mkdir -p downloads && mkdir -p dynamodb_local && wget -N https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz -P ./downloads && tar -xvf ./downloads/dynamodb_local_latest.tar.gz -C ./dynamodb_local",
"dynamodb:start": "java -Djava.library.path=./dynamodb_local/DynamoDBLocal_lib -jar ./dynamodb_local/DynamoDBLocal.jar -sharedDb -inMemory",
"release": "rm -f subway.zip && yarn --production && zip -r subway.zip . -x '*.git*' -x 'tests/*' -x 'downloads/*' -x 'dynamodb_local/*'",
"test": "NODE_ENV=test ava"
},
"ava": {
Expand Down
14 changes: 14 additions & 0 deletions tests/index-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import fs from 'fs';
import { spawn } from 'child_process';

import test from 'ava';
import LambdaTester from 'lambda-tester';
import fetchMock from 'fetch-mock';

import { handler, flashBriefingHandler } from '../index.js';

var dynamo;

test.cb.before(t => {
dynamo = spawn('yarn run dynamodb:start', { shell: true, timeout: 3000 });
setTimeout(t.end, 3000);
})

test.cb.after.always(t => {
dynamo.on('exit', () => t.end());
setTimeout(t.end, 3000);
dynamo.kill('SIGINT');
})

test.serial('flashBriefingHandler', async t => {
t.plan(3);

Expand Down

0 comments on commit 1b4a48d

Please sign in to comment.