Skip to content

Commit

Permalink
popall and getall bug while data empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ericdum committed Feb 3, 2015
1 parent 9ea382a commit 5992615
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/index.coffee
Expand Up @@ -108,6 +108,8 @@ class File_DB
result = {}
for key, position of data
func.push @_getdataMaker key, position
unless func.length
return cb null, result
flow = ep()
flow.lazy func
flow.lazy ->
Expand All @@ -128,6 +130,8 @@ class File_DB
result = {}
for key, position of data
func.push @_popdataMaker key, position
unless func.length
return cb null, result
flow = ep()
flow.lazy func
flow.lazy ->
Expand Down
6 changes: 6 additions & 0 deletions out/release/lib/index.js

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
@@ -1,6 +1,6 @@
{
"name": "shared-memory",
"version": "0.1.1",
"version": "0.1.2",
"description": "A k-v database using /shm/ to shared memory",
"keywords": "shared, memory, kv, db, shm",
"homepage": "https://github.com/ericdum/node-shared-memory",
Expand Down
26 changes: 26 additions & 0 deletions test.js
Expand Up @@ -145,6 +145,19 @@ describe("getAll", function(){
done()
})
})

it('get empty data', function(done){
_c = db.index.getAll;
db.index.getAll = function(cb){
db.index.getAll = _c;
cb(null, {})
}
db.getAll(function(err, data){
expect(err).to.not.be.ok()
expect(data).to.be.eql({})
done()
})
})
});

describe("popAll", function(){
Expand All @@ -161,6 +174,19 @@ describe("popAll", function(){
})
})
})

it('pop empty data', function(done){
_c = db.index.getAll;
db.index.getAll = function(cb){
db.index.getAll = _c;
cb(null, {})
}
db.popAll(function(err, data){
expect(err).to.not.be.ok()
expect(data).to.be.eql({})
done()
})
})
});

function regularExpect(key, value, cb) {
Expand Down

0 comments on commit 5992615

Please sign in to comment.