This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Database.js
60 lines (48 loc) · 1.69 KB
/
Database.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
var should = require("should")
, dynamo = require("../../")
, client = dynamo.createClient()
, db = client.get("us-east-1")
describe("Database", function() {
describe("#get()", function() {
it("should return the appropriate object", function() {
var table = db.get("table")
, batch = db.get(function(){})
, item = db.get("table", {id: 123})
table.should.have.property("TableName", "table")
table.should.have.property("database", db)
batch.should.have.property("RequestItems")
batch.should.have.property("database", db)
item.should.have.property("TableName", "table")
item.should.have.property("Key")
item.should.have.property("database", db)
})
})
describe("#add()", function() {
it("should return a table", function() {
var table = db.add({name: "table", schema: {id: 123}})
table.should.have.property("TableName", "table")
table.should.have.property("KeySchema")
})
})
describe("#put()", function() {
it("should return an update", function() {
var update = db.put("table", {id: 123})
update.should.have.property("TableName", "table")
update.should.have.property("Item")
update.Item.should.have.property("id")
})
})
describe("#fetch()", function() {
it("should return a hash of tables", function(done) {
db.fetch(function(err, database) {
should.not.exist(err)
should.exist(database)
database.should.equal(db)
database.should.have.property("tables")
database.tables.should.have.property("DYNAMO_TEST_TABLE_1")
database.tables.should.have.property("DYNAMO_TEST_TABLE_2")
done()
})
})
})
})