This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 44
Remove levelup from destroy tests #136
Merged
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
'use strict' | ||
|
||
var levelup = require('levelup') | ||
|
||
module.exports = function (leveljs, test, testCommon) { | ||
test('setUp', testCommon.setUp) | ||
|
||
|
@@ -165,46 +163,58 @@ module.exports = function (leveljs, test, testCommon) { | |
// NOTE: in chrome (at least) indexeddb gets buggy if you try and destroy a db, | ||
// then create it again, then try and destroy it again. these avoid doing that | ||
|
||
test('test levelup .destroy', function (t) { | ||
test('test .destroy', function (t) { | ||
var location = testCommon.location() | ||
var db = levelup(leveljs(location)) | ||
db.put('key', 'value', function (err) { | ||
var db = leveljs(location) | ||
db.open(function (err) { | ||
t.notOk(err, 'no error') | ||
db.get('key', { asBuffer: false }, function (err, value) { | ||
db.put('key', 'value', function (err) { | ||
t.notOk(err, 'no error') | ||
t.equal(value, 'value', 'should have value') | ||
db.close(function (err) { | ||
db.get('key', { asBuffer: false }, function (err, value) { | ||
t.notOk(err, 'no error') | ||
leveljs.destroy(location, function (err) { | ||
t.equal(value, 'value', 'should have value') | ||
db.close(function (err) { | ||
t.notOk(err, 'no error') | ||
var db2 = levelup(leveljs(location)) | ||
db2.get('key', { asBuffer: false }, function (err, value) { | ||
t.ok(err && err.notFound, 'key is not there') | ||
db2.close(t.end.bind(t)) | ||
leveljs.destroy(location, function (err) { | ||
t.notOk(err, 'no error') | ||
var db2 = leveljs(location) | ||
db2.open(function (err) { | ||
t.notOk(err, 'no error') | ||
db2.get('key', { asBuffer: false }, function (err, value) { | ||
t.is(err.message, 'NotFound', 'key is not there') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error is different since |
||
db2.close(t.end.bind(t)) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
test('test levelup .destroy and custom prefix', function (t) { | ||
test('test .destroy and custom prefix', function (t) { | ||
var location = testCommon.location() | ||
var prefix = 'CUSTOM-PREFIX-' | ||
var db = levelup(leveljs(location, { prefix: prefix })) | ||
db.put('key', 'value', function (err) { | ||
var prefix = 'custom-' | ||
var db = leveljs(location, { prefix: prefix }) | ||
db.open(function (err) { | ||
t.notOk(err, 'no error') | ||
db.get('key', { asBuffer: false }, function (err, value) { | ||
db.put('key', 'value', function (err) { | ||
t.notOk(err, 'no error') | ||
t.equal(value, 'value', 'should have value') | ||
db.close(function (err) { | ||
db.get('key', { asBuffer: false }, function (err, value) { | ||
t.notOk(err, 'no error') | ||
leveljs.destroy(location, prefix, function (err) { | ||
t.equal(value, 'value', 'should have value') | ||
db.close(function (err) { | ||
t.notOk(err, 'no error') | ||
var db2 = levelup(leveljs(location, { prefix: prefix })) | ||
db2.get('key', { asBuffer: false }, function (err, value) { | ||
t.ok(err && err.notFound, 'key is not there') | ||
db2.close(t.end.bind(t)) | ||
leveljs.destroy(location, prefix, function (err) { | ||
t.notOk(err, 'no error') | ||
var db2 = leveljs(location, { prefix: prefix }) | ||
db2.open(function (err) { | ||
t.notOk(err, 'no error') | ||
db2.get('key', { asBuffer: false }, function (err, value) { | ||
t.is(err.message, 'NotFound', 'key is not there') | ||
db2.close(t.end.bind(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
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.
Had to rewrite tests a bit since
levelup
takes care ofdb.open()
.