diff --git a/index.js b/index.js index d07bebb..884638a 100644 --- a/index.js +++ b/index.js @@ -22,6 +22,10 @@ function ddbtest(test, projectName, tableDef, region, port) { var live = !!region; tableDef = _(tableDef).clone(); + // DynamoDB's TimeToLiveSpecification is not valid for aws-sdk's createTable + // and is not supported in dynalite, so remove it. + delete tableDef.TimeToLiveSpecification; + function getKeys(item) { var keyNames = tableDef.KeySchema.map(function(key) { return key.AttributeName; diff --git a/test/index.test.js b/test/index.test.js index 889ef04..d6c5f99 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -41,6 +41,13 @@ test('respects port option', function(assert) { assert.end(); }); +test('removes TimeToLiveSpecification', function(assert) { + var tableDefWithTTL = _({ TimeToLiveSpecification: { Enabled: true }}).defaults(mocked.tableDef); + var db = require('..')(test, project, tableDefWithTTL); + assert.notOk(db.tableDef.TimeToLiveSpecification, 'TimeToLiveSpecification is removed'); + assert.end(); +}); + mocked.start(); test('mocked start', function(assert) { @@ -85,6 +92,22 @@ test('mock two tables', function(assert) { }); secondMock.delete(); + +var tableDefWithTTL = _({ TimeToLiveSpecification: { Enabled: true }}).defaults(mocked.tableDef); +var mockWithTTL = require('..')(test, project, tableDefWithTTL); +mockWithTTL.start(); + +test('mock with TTL', function(assert) { + mockWithTTL.dynamo.listTables({}, function(err, data) { + if (err) throw err; + assert.notOk(mockWithTTL.tableDef.TimeToLiveSpecification, 'should not have TimeToLiveSpecification'); + assert.ok(data.TableNames.indexOf(mockWithTTL.tableName) > -1, 'created table'); + assert.end(); + }); +}); + +mockWithTTL.delete(); + mocked.delete(); test('mocked delete', function(assert) {