This repository has been archived by the owner on Dec 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 56
update abstract-leveldown to v4 #28
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
76c15ee
fix(package): update abstract-leveldown to version 4.0.0
greenkeeper[bot] 827a125
ranges-test.js -> iterator-range-test.js
ralphtheninja 7d40430
move approximateSize and tests from abstract-leveldown
ralphtheninja 16aa902
remove testBuffer from put-get-del-test.js
ralphtheninja e8b099b
use default testCommon from abstract-leveldown + remove unused testCo…
ralphtheninja 7355ede
add missing tearDown on compact-range-test
ralphtheninja af2916a
add missing location to fs.existsSync()
ralphtheninja 2c87099
where did I get 2 from?
ralphtheninja 3b9d251
ensure there is no error after cleanup(cb)
ralphtheninja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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('../') | ||
, 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('../') | ||
, 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
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('../') | ||
, 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('../') | ||
, 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
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,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) |
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')) | ||
, 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('../') | ||
, abstract = require('abstract-leveldown/abstract/put-test') | ||
|
||
abstract.all(leveldown, test, testCommon) | ||
abstract.all(leveldown, test) |
This file was deleted.
Oops, something went wrong.
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's a timing issue to use
fs.existsSync()
on windows or if it's actually a bug. Clearly, not usinglocation
is incorrect.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I almost never use
fs.exist(Sync)
, I'm not aware of any timing issues.It could be the same issue as in
leveldown
, that some test isn't closing itsdb
, but inleveldown
, we sawEBUSY
rather thanEPERM
errors.No promises as to when, but I'll try to take a look at this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, should have read the code, it actually does close the
db
. Hmm that's greatThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Able to reproduce. There are no leftover files, but it seems the directory itself (
location
) isn't removed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So maybe the test should actually check for an empty folder, rather than the folder itself being removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worse..
leveldown.destroy
actually creates the directory.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repro:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, we could do:
And open an issue to fix the destroy bug later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #30 for the bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O.o