-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rename ranges-test.js iterator-range-test.js * add missing tearDown for compact range test * assert no errors after cleanup * 🚚 move over implementation of approximateSize() from abstract-leveldown (fixes tests) * update tests using testCommon defaults * use .. consistenly when requiring leveldown * 🔥 remove testBuffer * use abstract-leveldown@4.0.0
- Loading branch information
1 parent
990e22f
commit 241e97c
Showing
25 changed files
with
207 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
const test = require('tape') | ||
, testCommon = require('abstract-leveldown/testCommon') | ||
, leveldown = require('../') | ||
, leveldown = require('..') | ||
, abstract = require('abstract-leveldown/abstract/batch-test') | ||
|
||
abstract.all(leveldown, test, testCommon) | ||
abstract.all(leveldown, test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
const test = require('tape') | ||
, testCommon = require('abstract-leveldown/testCommon') | ||
, leveldown = require('../') | ||
, leveldown = require('..') | ||
, abstract = require('abstract-leveldown/abstract/chained-batch-test') | ||
|
||
abstract.all(leveldown, test, testCommon) | ||
abstract.all(leveldown, test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
const test = require('tape') | ||
, testCommon = require('abstract-leveldown/testCommon') | ||
, leveldown = require('../') | ||
, leveldown = require('..') | ||
, abstract = require('abstract-leveldown/abstract/del-test') | ||
|
||
abstract.all(leveldown, test, testCommon) | ||
abstract.all(leveldown, test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
const test = require('tape') | ||
, testCommon = require('abstract-leveldown/testCommon') | ||
, leveldown = require('../') | ||
, leveldown = require('..') | ||
, abstract = require('abstract-leveldown/abstract/get-test') | ||
|
||
abstract.all(leveldown, test, testCommon) | ||
abstract.all(leveldown, test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const test = require('tape') | ||
, leveldown = require('..') | ||
, abstract = require('abstract-leveldown/abstract/iterator-range-test') | ||
|
||
abstract.all(leveldown, test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const test = require('tape') | ||
, leveldown = require('../') | ||
, leveldown = require('..') | ||
, abstract = require('abstract-leveldown/abstract/leveldown-test') | ||
|
||
abstract.args(leveldown, test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
const test = require('tape') | ||
, testCommon = require('abstract-leveldown/testCommon') | ||
, leveldown = require('../') | ||
, leveldown = require('..') | ||
, abstract = require('abstract-leveldown/abstract/open-test') | ||
|
||
abstract.all(leveldown, test, testCommon) | ||
abstract.all(leveldown, test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
const test = require('tape') | ||
, testCommon = require('abstract-leveldown/testCommon') | ||
, leveldown = require('../') | ||
, fs = require('fs') | ||
, path = require('path') | ||
, testBuffer = fs.readFileSync(path.join(__dirname, 'data/testdata.bin')) | ||
, leveldown = require('..') | ||
, abstract = require('abstract-leveldown/abstract/put-get-del-test') | ||
|
||
abstract.all(leveldown, test, testCommon, testBuffer) | ||
abstract.all(leveldown, test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
const test = require('tape') | ||
, testCommon = require('abstract-leveldown/testCommon') | ||
, leveldown = require('../') | ||
, leveldown = require('..') | ||
, abstract = require('abstract-leveldown/abstract/put-test') | ||
|
||
abstract.all(leveldown, test, testCommon) | ||
abstract.all(leveldown, test) |
Oops, something went wrong.