Skip to content

Commit

Permalink
Ignore TimeToLiveSpecification from tableDef (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
jseppi authored May 26, 2020
1 parent 64fe6b9 commit e497f03
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e497f03

Please sign in to comment.