I am running a pair of Docker containers, one with DynamoDB local running and the other running Nodejs. They are linked and I can confirm the link is working by running :
$ aws dynamodb list-tables --endpoint-url=http://dynamodb:8000
I don't think this is part of the problem, I'm just listing it here for completeness.
However, I can't get the following test script in mocha to work. The test just times out:
Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
Here's the test script:
'use strict';
var expect = require('chai').expect;
var aws = require('aws-sdk');
aws.config.update({ accessKeyId: 'fakeAccessKey', secretAccessKey: 'fakeSecretAccessKey', region: 'fakeRegion', });
var db = new aws.DynamoDB({ params: { endpoint: 'http://dynamodb:8000' }});
describe('queue-handler', function() {
it('should connect to dynamodb and list tables', function(done) {
console.log("Check for tables...");
db.listTables({}, function(err, data) {
console.log("list tables returned.");
if(err)
console.log("Error listTables: " + JSON.stringify(err, null, 2));
else
console.log("listTables: " + JSON.stringify(data, null, 2));
done();
});
});
});
I can see "Check for tables..." logged, but not "list tables returned.".
The documentation suggests that endpoint
should be a "direct" property to the options object (and not nested in params
):
var db = new aws.DynamoDB({ endpoint: 'http://dynamodb:8000' });