From c64c1ba7be2c14bd857f83e85a35511cfd1a53c8 Mon Sep 17 00:00:00 2001 From: Nick Santos Date: Mon, 22 Jun 2015 15:58:07 -0700 Subject: [PATCH] fix heap space option, and add tests --- lib/launch.js | 2 +- package.json | 8 ++++++-- test/launch_test.js | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 test/launch_test.js diff --git a/lib/launch.js b/lib/launch.js index 2d53fb9..f6bde07 100644 --- a/lib/launch.js +++ b/lib/launch.js @@ -48,7 +48,7 @@ function launch(options, port) { ] if (options.heap) { - args.push('-Xmx=' + options.heap) + args.push('-Xmx' + options.heap) } args.push( diff --git a/package.json b/package.json index f5c1284..98b7745 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "local-dynamo", "description": "A Node.js wrapper of AWS DynamoDB Local and utilities", - "version": "0.1.0", + "version": "0.1.1", "homepage": "https://github.com/Medium/local-dynamo", "licenses": [ { @@ -23,6 +23,9 @@ "type": "git", "url": "https://github.com/Medium/local-dynamo.git" }, + "scripts": { + "test": "./node_modules/.bin/nodeunit test" + }, "dependencies": { "flags": "0.1.2", "kew": "0.4.0", @@ -30,6 +33,7 @@ "progress": "1.1.8" }, "devDependencies": { - "aws-sdk": "^2.0.22" + "aws-sdk": "^2.0.22", + "nodeunit": "0.9.1" } } diff --git a/test/launch_test.js b/test/launch_test.js new file mode 100644 index 0000000..b0658b8 --- /dev/null +++ b/test/launch_test.js @@ -0,0 +1,33 @@ +// Copyright 2015 A Medium Corporation. + +var localDynamo = require('../lib/launch') + +exports.testMemory = function (test) { + var dynamo = localDynamo.launch({ + port: 8676, + heap: '512m' + }) + dynamo.stdout.on('data', function (data) { + console.log('stdout', data.toString()) + }) + dynamo.stderr.on('data', function (data) { + console.log('stderr', data.toString()) + }) + + var finished = false + + dynamo.on('exit', function (code) { + if (finished) return + + finished = true + test.ok(false, 'Unexpected exit code ' + code) + test.done() + }) + + // If everything goes well after 5 seconds, then we're done! + setTimeout(function () { + finished = true + dynamo.kill() + test.done() + }, 5000).unref() +}