Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore TimeToLiveSpecification from tableDef #4

Merged
merged 3 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mapbox/dynamodb-test",
"version": "0.4.0",
"version": "0.5.0-dev.1",
"description": "Create and destroy DynamoDB and Dynalite tables for use in tape tests",
"main": "index.js",
"scripts": {
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