forked from dscdac/serverless-dynamodb-local
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestTable.js
67 lines (62 loc) · 1.96 KB
/
testTable.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"use strict";
//Define the modules required to mocha testing
const assert = require("chai").assert;
const http = require ("http");
const expect = require("chai").expect;
const should = require("should");
const aws = require ("aws-sdk");
const dynamodbLocal = require("../index.js");
aws.config.update({ accessKeyId: "localAccessKey", secretAccessKey: "localSecretAccessKey", region: "localRegion"});
var db = new aws.DynamoDB({ endpoint: 'http://localhost:8000' });
describe("Check Table operations", function() {
describe("#update table", function(){
this.timeout(50000);
it("should update the table", function(done){
var params = {
"AttributeDefinitions": [
{
"AttributeName": "batch",
"AttributeType": "N"
}
],
"ProvisionedThroughput": {
"ReadCapacityUnits": 10,
"WriteCapacityUnits": 10
},
"TableName": "Movies"
}
db.updateTable(params,function(err,data){
if (err){
should.not.exist(data);
} else {
data.TableDescription.should.have.property("TableName","Movies");
should.exist(data);
}
done();
});
});
});
describe("queue-handler", function() {
this.timeout(50000);
it("should connect to dynamodb and list tables", function(done) {
db.listTables({}, function(err, data) {
if(err){
should.exist(err);
} else {
expect(data.TableNames).to.be.empty;
}
done();
});
});
});
describe("#getItems", function() {
this.timeout(50000);
var tableDes = db.getItem({"TableName": "Movies"})
it("Retrieve hostname from created tables", function() {
assert.equal(tableDes.httpRequest.endpoint.hostname,"localhost");
});
it("Retrieves the path of the table",function(){
assert.equal(tableDes.httpRequest.path, "/");
});
});
});