From 76c15ee7b746fdee48be39a32569f55516172aae Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 20 Jan 2018 15:39:56 +0000 Subject: [PATCH 1/9] fix(package): update abstract-leveldown to version 4.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bd74d4ec..56628b86 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "main": "leveldown.js", "typings": "leveldown.d.ts", "dependencies": { - "abstract-leveldown": "~3.0.0", + "abstract-leveldown": "~4.0.0", "bindings": "~1.3.0", "fast-future": "~1.0.2", "nan": "~2.8.0", From 827a125ea3c71f568b6b753177070b4dece44463 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sun, 21 Jan 2018 20:57:33 +0100 Subject: [PATCH 2/9] ranges-test.js -> iterator-range-test.js --- test/iterator-range-test.js | 5 +++++ test/ranges-test.js | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 test/iterator-range-test.js delete mode 100644 test/ranges-test.js diff --git a/test/iterator-range-test.js b/test/iterator-range-test.js new file mode 100644 index 00000000..c6a2a164 --- /dev/null +++ b/test/iterator-range-test.js @@ -0,0 +1,5 @@ +const test = require('tape') + , leveldown = require('..') + , abstract = require('abstract-leveldown/abstract/iterator-range-test') + +abstract.all(leveldown, test) diff --git a/test/ranges-test.js b/test/ranges-test.js deleted file mode 100644 index 7f16a2d0..00000000 --- a/test/ranges-test.js +++ /dev/null @@ -1,6 +0,0 @@ -const test = require('tape') - , testCommon = require('abstract-leveldown/testCommon') - , leveldown = require('../') - , abstract = require('abstract-leveldown/abstract/ranges-test') - -abstract.all(leveldown, test, testCommon) From 7d40430400c4abb6e645e250fb7a17e1cb1e03ae Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sun, 21 Jan 2018 20:58:12 +0100 Subject: [PATCH 3/9] move approximateSize and tests from abstract-leveldown --- leveldown.js | 16 ++++- test/approximate-size-test.js | 127 ++++++++++++++++++++++++++++++++-- 2 files changed, 137 insertions(+), 6 deletions(-) diff --git a/leveldown.js b/leveldown.js index 477654bb..1d3cdb3d 100644 --- a/leveldown.js +++ b/leveldown.js @@ -53,7 +53,21 @@ LevelDOWN.prototype._batch = function (operations, options, callback) { } -LevelDOWN.prototype._approximateSize = function (start, end, callback) { +LevelDOWN.prototype.approximateSize = function (start, end, callback) { + if (start == null || + end == null || + typeof start === 'function' || + typeof end === 'function') { + throw new Error('approximateSize() requires valid `start`, `end` and `callback` arguments') + } + + if (typeof callback !== 'function') { + throw new Error('approximateSize() requires a callback argument') + } + + start = this._serializeKey(start) + end = this._serializeKey(end) + this.binding.approximateSize(start, end, callback) } diff --git a/test/approximate-size-test.js b/test/approximate-size-test.js index 31038a48..0e662d64 100644 --- a/test/approximate-size-test.js +++ b/test/approximate-size-test.js @@ -1,6 +1,123 @@ -const test = require('tape') - , testCommon = require('abstract-leveldown/testCommon') - , leveldown = require('../') - , abstract = require('abstract-leveldown/abstract/approximate-size-test') +const test = require('tape') +const leveldown = require('..') +const testCommon = require('abstract-leveldown/testCommon') -abstract.all(leveldown, test, testCommon) +var db + +test('setUp common for approximate size', testCommon.setUp) + +test('setUp db', function (t) { + db = leveldown(testCommon.location()) + console.log('db', db) + db.open(t.end.bind(t)) +}) + +test('test argument-less approximateSize() throws', function (t) { + t.throws( + db.approximateSize.bind(db) + , { name: 'Error', message: 'approximateSize() requires valid `start`, `end` and `callback` arguments' } + , 'no-arg approximateSize() throws' + ) + t.end() +}) + +test('test callback-less, 1-arg, approximateSize() throws', function (t) { + t.throws( + db.approximateSize.bind(db, 'foo') + , { name: 'Error', message: 'approximateSize() requires valid `start`, `end` and `callback` arguments' } + , 'callback-less, 1-arg approximateSize() throws' + ) + t.end() +}) + +test('test callback-less, 2-arg, approximateSize() throws', function (t) { + t.throws( + db.approximateSize.bind(db, 'foo', 'bar') + , { name: 'Error', message: 'approximateSize() requires a callback argument' } + , 'callback-less, 2-arg approximateSize() throws' + ) + t.end() +}) + +test('test callback-less, 3-arg, approximateSize() throws', function (t) { + t.throws( + db.approximateSize.bind(db, function () {}) + , { name: 'Error', message: 'approximateSize() requires valid `start`, `end` and `callback` arguments' } + , 'callback-only approximateSize() throws' + ) + t.end() +}) + +test('test callback-only approximateSize() throws', function (t) { + t.throws( + db.approximateSize.bind(db, function () {}) + , { name: 'Error', message: 'approximateSize() requires valid `start`, `end` and `callback` arguments' } + , 'callback-only approximateSize() throws' + ) + t.end() +}) + +test('test 1-arg + callback approximateSize() throws', function (t) { + t.throws( + db.approximateSize.bind(db, 'foo', function () {}) + , { name: 'Error', message: 'approximateSize() requires valid `start`, `end` and `callback` arguments' } + , '1-arg + callback approximateSize() throws' + ) + t.end() +}) + +test('test custom _serialize*', function (t) { + t.plan(4) + var db = leveldown(testCommon.location()) + db._serializeKey = function (data) { return data } + db.approximateSize = function (start, end, callback) { + t.deepEqual(start, { foo: 'bar' }) + t.deepEqual(end, { beep: 'boop' }) + process.nextTick(callback) + } + db.open(function () { + db.approximateSize({ foo: 'bar' }, { beep: 'boop' }, function (err) { + t.error(err) + db.close(t.error.bind(t)) + }) + }) +}) + +test('test approximateSize()', function (t) { + var data = Array.apply(null, Array(10000)).map(function () { + return 'aaaaaaaaaa' + }).join('') + + db.batch(Array.apply(null, Array(10)).map(function (x, i) { + return { type: 'put', key: 'foo' + i, value: data } + }), function (err) { + t.error(err) + + // cycle open/close to ensure a pack to .sst + + db.close(function (err) { + t.error(err) + + db.open(function (err) { + t.error(err) + + db.approximateSize('!', '~', function (err, size) { + t.error(err) + + t.equal(typeof size, 'number') + // account for snappy compression, original would be ~100000 + t.ok(size > 40000, 'size reports a reasonable amount (' + size + ')') + + db.close(function (err) { + t.error(err) + t.end() + }) + }) + }) + }) + }) +}) + +test('tearDown', function (t) { + db.close(testCommon.tearDown.bind(null, t)) +}) From 16aa902aeb8fb87db3e3bdfd70e75c314cc29ee8 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sun, 21 Jan 2018 21:06:57 +0100 Subject: [PATCH 4/9] remove testBuffer from put-get-del-test.js --- test/data/testdata.bin | Bin 4688 -> 0 bytes test/put-get-del-test.js | 5 +---- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 test/data/testdata.bin diff --git a/test/data/testdata.bin b/test/data/testdata.bin deleted file mode 100644 index 59229b942a3cb91ad45a4102d4b01a8b46b60dbb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4688 zcmd^D`8$+t`@hG&SF%NEnvg~qqp>T@5H%!}r92vAFc>q9v6HosCHp>6${rHgB9uLa zEFnvgELmc#VczL^pPu*o!}odrf%iI&`@XL0JkHPOJkRU=T*q-AcZ9Lg1zs*uE&u>{ z4fIhaj9H8EXmBty-k;6U*BH|gimnC4lxR=!#E@}-wjI$H2R0yJ9B?K$jGgzb4x9!6 zFiYUgEGQO+Xf-U6Acy(oBj-gRG0+UM^Ijwj))_|u+u|JXu9}eLx>pb|-cA!@jxdB7 zl8`t@yuJ?^XX;~QhV^mAs@g%$p95=nsWAu$I0^>rMR0L-Q}fb<{K>1vSpPE1L%@H! zP@FX(|4z!n&=`y)l5t>!984AqQ&Ipcot0BK3sXI-dIk)KDZu0v;PNnKSp}FHLRk%_ z0RC%07}3af_G%_5y}x2HcA5}J3WcO5FYoE;Dd(vuM6x~CAw2IA&gA_T>^phH?6DNU&q8aFnKQwNnSw? z_N%1dj)sQ+-IYN2+uMy|g8NUt|1YtdnKub1Z-R3px|6Yt#@V0z6^f*WB;zm?BH4^c zboqUX#*Rb^(an)a0wYZkatdHW3>NSD%kn3}&`{05)s2F2#o`Q5nh*wu93F3{hJfoJ zbyQFaN(gO51qEFN9aRKUTNwpcQbj2uw2|=NSQHWKPQbZReq-(agN6Si_Lmq4Bt~Qu zj*R!f+3Asq1n{3ltKt7K7o^@l^8JOi`{!I>|A>`mBqRT;wg0EpzfBDN{967kT*l^a z>Em1(dM7i4?NH{Yz_>4fG1^R5K6hxX@(i`Eb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p#7mH@6Q~O%*e=vT;oora6h?iUDpj+sreBZ$}&3 zzUA!s+qh>-&HpSPoM?_kHFivyL0{kG-Jw^f9%q75Z-)gX93jB&0!C>lgcwkctMmUO z&!ZR>Sg3z)e3UPT>h#*QL&)Y}pa?>tumgTJKB$-5=Mx~3!Mb(k`plX`)%)rzSFXBl z+x8TF{^NRvY8nSK&6?`sBmB;OLd>+VTT@-Ee~U-Vm*?hpy&0^mL~>C3TPKO5WU+fm zO(Lw&U7MUx``~RJ@X_tCR|_%8&-km*w=4J>lek!+ zO-_nDG&!Ej+3(T8sE0bIc8>;9}k?O zfuw!&cmPMRo{j)kS~^^tDa6$z@NkyJF@y3IQq~IIS#BiaqtWNayqnNLEu$NoLl>sP zUz{6RfV1thp-+YMvI;F`4>I5G9xWX(7)Nk(q-=luP<>-$V6H$;OWRo5{d{^0btHbV zC8I;UgbCap^r6cy?M8YuCVGH5*|Hs*hDc|9@M*Ovxwfj(B@_MP7gPsth3u^T>Zzk$bT98!(z<%yPkAc>Z)iD5O=`V?ii6I>w81*XqEMSZl`<4<-1S59LOird2H5-z;w%_Q_Ux zT1W8claX7s)gxaVmnofoB4OQ-Y4-gqj$cIB_w(&^%Y*kCGgI~0I$1y}8UbzXFmooM za;GGk-7WHumcyqFyjdn&s39$-QZ8en8A8I+hMt|7po4b-bcU`NMon-!^Xj@Ve{+1~ z0mvoQ)VM1e;qgvFA|j4Tp%mjSkuv{VENs4f_4*5iJ3FOSepytifY7z5GgB2QLvsgS z)<3CYCL?yH+yaYqhPG8x6{etVN>F2~P6~6;{Di)~e*3$3M*7vUu?N*9*6S7%i&AAA znjxtb!}v_~FDh_e;aNN6^JC_Q@#GBpS8EDmHA;^E93>gmzN^7fZXnJB5p$bS>?kMn?>C3PY~)A zE Date: Sun, 21 Jan 2018 21:08:15 +0100 Subject: [PATCH 5/9] use default testCommon from abstract-leveldown + remove unused testCommon variables --- test/batch-test.js | 3 +-- test/chained-batch-test.js | 3 +-- test/cleanup-hanging-iterators-test.js | 1 - test/close-test.js | 2 +- test/del-test.js | 3 +-- test/destroy-test.js | 1 - test/get-test.js | 3 +-- test/iterator-test.js | 5 ++--- test/open-test.js | 3 +-- test/put-get-del-test.js | 3 +-- test/put-test.js | 3 +-- test/repair-test.js | 1 - 12 files changed, 10 insertions(+), 21 deletions(-) diff --git a/test/batch-test.js b/test/batch-test.js index c93e6eff..ed4e3779 100644 --- a/test/batch-test.js +++ b/test/batch-test.js @@ -1,6 +1,5 @@ const test = require('tape') - , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/batch-test') -abstract.all(leveldown, test, testCommon) +abstract.all(leveldown, test) diff --git a/test/chained-batch-test.js b/test/chained-batch-test.js index cc20f9e4..bf3417ac 100644 --- a/test/chained-batch-test.js +++ b/test/chained-batch-test.js @@ -1,6 +1,5 @@ const test = require('tape') - , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/chained-batch-test') -abstract.all(leveldown, test, testCommon) +abstract.all(leveldown, test) diff --git a/test/cleanup-hanging-iterators-test.js b/test/cleanup-hanging-iterators-test.js index 3ed394e6..c9e6ec7a 100644 --- a/test/cleanup-hanging-iterators-test.js +++ b/test/cleanup-hanging-iterators-test.js @@ -1,5 +1,4 @@ const test = require('tape') - , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , makeTest = require('./make') diff --git a/test/close-test.js b/test/close-test.js index ae5d3bf8..81fbe3bb 100644 --- a/test/close-test.js +++ b/test/close-test.js @@ -15,7 +15,7 @@ module.exports.tearDown = function () { module.exports.all = function (leveldown) { module.exports.setUp() - module.exports.close(leveldown, test, testCommon) + module.exports.close(leveldown, test) module.exports.tearDown() } diff --git a/test/del-test.js b/test/del-test.js index b21712be..bd31e207 100644 --- a/test/del-test.js +++ b/test/del-test.js @@ -1,6 +1,5 @@ const test = require('tape') - , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/del-test') -abstract.all(leveldown, test, testCommon) +abstract.all(leveldown, test) diff --git a/test/destroy-test.js b/test/destroy-test.js index eea78a57..8d334f1d 100644 --- a/test/destroy-test.js +++ b/test/destroy-test.js @@ -3,7 +3,6 @@ const test = require('tape') , path = require('path') , mkfiletree = require('mkfiletree') , readfiletree = require('readfiletree') - , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , makeTest = require('./make') diff --git a/test/get-test.js b/test/get-test.js index 52270ad3..949eeb6d 100644 --- a/test/get-test.js +++ b/test/get-test.js @@ -1,6 +1,5 @@ const test = require('tape') - , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/get-test') -abstract.all(leveldown, test, testCommon) +abstract.all(leveldown, test) diff --git a/test/iterator-test.js b/test/iterator-test.js index 21f2ce79..d22a1ed6 100644 --- a/test/iterator-test.js +++ b/test/iterator-test.js @@ -1,5 +1,4 @@ const test = require('tape') - , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/iterator-test') , make = require('./make') @@ -7,7 +6,7 @@ const test = require('tape') , lexi = require('lexicographic-integer') , util = require('util') -abstract.all(leveldown, test, testCommon) +abstract.all(leveldown, test) make('iterator throws if key is not a string or buffer', function (db, t, done) { var keys = [null, undefined, 1, true, false] @@ -288,4 +287,4 @@ function not (n) { function even (n) { return n % 2 === 0 -} \ No newline at end of file +} diff --git a/test/open-test.js b/test/open-test.js index 0da638a3..f2a7c168 100644 --- a/test/open-test.js +++ b/test/open-test.js @@ -1,6 +1,5 @@ const test = require('tape') - , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/open-test') -abstract.all(leveldown, test, testCommon) +abstract.all(leveldown, test) diff --git a/test/put-get-del-test.js b/test/put-get-del-test.js index 50040f04..6bdaf780 100644 --- a/test/put-get-del-test.js +++ b/test/put-get-del-test.js @@ -1,6 +1,5 @@ const test = require('tape') - , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/put-get-del-test') -abstract.all(leveldown, test, testCommon) +abstract.all(leveldown, test) diff --git a/test/put-test.js b/test/put-test.js index e437f5ee..4663c9db 100644 --- a/test/put-test.js +++ b/test/put-test.js @@ -1,6 +1,5 @@ const test = require('tape') - , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , abstract = require('abstract-leveldown/abstract/put-test') -abstract.all(leveldown, test, testCommon) +abstract.all(leveldown, test) diff --git a/test/repair-test.js b/test/repair-test.js index 2b5cca62..774382aa 100644 --- a/test/repair-test.js +++ b/test/repair-test.js @@ -3,7 +3,6 @@ const test = require('tape') , path = require('path') , mkfiletree = require('mkfiletree') , readfiletree = require('readfiletree') - , testCommon = require('abstract-leveldown/testCommon') , leveldown = require('../') , makeTest = require('./make') From 7355edea80da05bebcc49f8ea7a61e0d921ffa73 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Thu, 25 Jan 2018 13:53:31 +0100 Subject: [PATCH 6/9] add missing tearDown on compact-range-test --- test/compact-range-test.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/test/compact-range-test.js b/test/compact-range-test.js index 135029af..64ce05fa 100644 --- a/test/compact-range-test.js +++ b/test/compact-range-test.js @@ -12,10 +12,10 @@ test('setUp db', function (t) { }) test('test compactRange() frees disk space after key deletion', function (t) { - var key1 = '000000'; - var key2 = '000001'; - var val1 = Buffer(64).fill(1); - var val2 = Buffer(64).fill(1); + var key1 = '000000' + var key2 = '000001' + var val1 = Buffer(64).fill(1) + var val2 = Buffer(64).fill(1) db.put(key1, val1, function() { db.put(key2, val2, function() { db.compactRange(key1, key2, function() { @@ -25,13 +25,17 @@ test('test compactRange() frees disk space after key deletion', function (t) { db.compactRange(key1, key2, function() { db.approximateSize('0', 'z', function(err, sizeAfterCompact) { t.ok(sizeAfterCompact < sizeAfterPuts); - t.end(); - }); - }); - }); - }); - }); - }); - }); - }); -}); + t.end() + }) + }) + }) + }) + }) + }) + }) + }) +}) + +test('tearDown', function (t) { + db.close(testCommon.tearDown.bind(null, 2)) +}) From af2916ae0cb90ffff4a9830eb9c9e5c6fe4e32d7 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Thu, 25 Jan 2018 13:53:42 +0100 Subject: [PATCH 7/9] add missing location to fs.existsSync() --- test/destroy-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/destroy-test.js b/test/destroy-test.js index 8d334f1d..8cfaee33 100644 --- a/test/destroy-test.js +++ b/test/destroy-test.js @@ -57,7 +57,7 @@ makeTest('test destroy() cleans and removes leveldb-only dir', function (db, t, db.close(function (err) { t.notOk(err, 'no error') leveldown.destroy(location, function () { - t.notOk(fs.existsSync(), 'directory completely removed') + t.notOk(fs.existsSync(location), 'directory completely removed') done(false) }) }) From 2c870999151b3eb8c1aabab27b0128d11c433eb9 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Thu, 25 Jan 2018 13:59:58 +0100 Subject: [PATCH 8/9] where did I get 2 from? --- test/compact-range-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/compact-range-test.js b/test/compact-range-test.js index 64ce05fa..1fef6d40 100644 --- a/test/compact-range-test.js +++ b/test/compact-range-test.js @@ -37,5 +37,5 @@ test('test compactRange() frees disk space after key deletion', function (t) { }) test('tearDown', function (t) { - db.close(testCommon.tearDown.bind(null, 2)) + db.close(testCommon.tearDown.bind(null, t)) }) From 3b9d251309b8551e0bef73c627b14eb67ce13c62 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Thu, 25 Jan 2018 17:30:21 +0100 Subject: [PATCH 9/9] ensure there is no error after cleanup(cb) --- test/make.js | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/test/make.js b/test/make.js index aeccf3b4..5729087c 100644 --- a/test/make.js +++ b/test/make.js @@ -8,28 +8,33 @@ function makeTest (name, testFn) { test(name, function (t) { cleanup(function () { var loc = location() - , db = leveldown(loc) - , done = function (close) { - if (close === false) - return cleanup(t.end.bind(t)) - db.close(function (err) { - t.notOk(err, 'no error from close()') - cleanup(t.end.bind(t)) - }) - } + var db = leveldown(loc) + var done = function (close) { + if (close === false) { + cleanup(function (err) { + t.error(err, 'no error after cleanup') + t.end() + }) + return + } + db.close(function (err) { + t.notOk(err, 'no error from close()') + cleanup(function (err) { + t.error(err, 'no error after cleanup') + t.end() + }) + }) + } db.open(function (err) { - t.notOk(err, 'no error from open()') - db.batch( - [ - { type: 'put', key: 'one', value: '1' } - , { type: 'put', key: 'two', value: '2' } - , { type: 'put', key: 'three', value: '3' } - ] - , function (err) { - t.notOk(err, 'no error from batch()') - testFn(db, t, done, loc) - } - ) + t.notOk(err, 'no error from open()') + db.batch([ + { type: 'put', key: 'one', value: '1' }, + { type: 'put', key: 'two', value: '2' }, + { type: 'put', key: 'three', value: '3' } + ], function (err) { + t.notOk(err, 'no error from batch()') + testFn(db, t, done, loc) + }) }) }) })