From d44b37c13d23d1edbb71eb37b017784f2e644d4b Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Sat, 16 Aug 2014 17:07:38 -0400 Subject: [PATCH] Add test for zero-length buffers with getBuffer/putBuffer --- tests/spec/providers/providers.base.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/spec/providers/providers.base.js b/tests/spec/providers/providers.base.js index e133d5d..ae60f48 100644 --- a/tests/spec/providers/providers.base.js +++ b/tests/spec/providers/providers.base.js @@ -91,6 +91,26 @@ module.exports = function createProviderTestsFor(providerName, testProvider) { }); }); + it("should allow zero-length Buffers with putBuffer() and getBuffer()", function(done) { + provider.open(function(error, firstAccess) { + if(error) throw error; + + var context = provider.getReadWriteContext(); + // Zero-length Filer Buffer + var buf = new Buffer(new ArrayBuffer(0)); + context.putBuffer("key", buf, function(error) { + if(error) throw error; + + context.getBuffer("key", function(error, result) { + expect(error).not.to.exist; + expect(Buffer.isBuffer(result)).to.be.true; + expect(result).to.deep.equal(buf); + done(); + }); + }); + }); + }); + it("should allow delete()", function(done) { var provider = _provider.provider; provider.open(function(error, firstAccess) {