level-packager
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -5,2 +5,10 @@ # Changelog | ||
## [3.1.0] - 2018-05-28 | ||
### Changed | ||
* Split up tests into `abstract/*-test.js` (@ralphtheninja) | ||
### Removed | ||
* Remove `.jshintrc` (@ralphtheninja) | ||
## [3.0.0] - 2018-05-23 | ||
@@ -20,4 +28,2 @@ | ||
### Fixed | ||
### Removed | ||
@@ -238,3 +244,4 @@ * Remove node 4 from Travis (@ralphtheninja) | ||
[Unreleased]: https://github.com/level/packager/compare/v3.0.0...HEAD | ||
[Unreleased]: https://github.com/level/packager/compare/v3.1.0...HEAD | ||
[3.1.0]: https://github.com/level/packager/compare/v3.0.0...v3.1.0 | ||
[3.0.0]: https://github.com/level/packager/compare/v2.1.1...v3.0.0 | ||
@@ -241,0 +248,0 @@ [2.1.1]: https://github.com/level/packager/compare/v2.1.0...v2.1.1 |
{ | ||
"name": "level-packager", | ||
"description": "LevelUP package helper for distributing with a LevelDOWN-compatible back-end", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"contributors": [ | ||
@@ -25,3 +25,3 @@ "Rod Vagg <r@va.gg> (https://github.com/rvagg)", | ||
"scripts": { | ||
"test": "standard && node test.js && rm -rf level-test*" | ||
"test": "standard && node test.js && rm -rf abstract/level-test*" | ||
}, | ||
@@ -28,0 +28,0 @@ "homepage": "https://github.com/Level/packager", |
118
test.js
'use strict' | ||
var fs = require('fs') | ||
var path = require('path') | ||
var location = path.join(__dirname, 'level-test-' + process.pid + '.db') | ||
module.exports = require('./abstract/test') | ||
module.exports = function (test, level, options) { | ||
options = options || {} | ||
test('Level constructor provides access to levelup errors', function (t) { | ||
t.ok(level.errors, '.errors property set on constructor') | ||
t.end() | ||
}) | ||
test('test db open and use, level(location, cb)', function (t) { | ||
level(location, function (err, db) { | ||
t.notOk(err, 'no error') | ||
db.put('test1', 'success', function (err) { | ||
t.notOk(err, 'no error') | ||
db.close(t.end.bind(t)) | ||
}) | ||
}) | ||
}) | ||
test('test db open and use, level(location, options, cb)', function (t) { | ||
level(location, { createIfMissing: false, errorIfExists: false }, function (err, db) { | ||
t.notOk(err, 'no error') | ||
db.put('test2', 'success', function (err) { | ||
t.notOk(err, 'no error') | ||
db.close(t.end.bind(t)) | ||
}) | ||
}) | ||
}) | ||
if (!options.skipErrorIfExistsTest) { | ||
// should use existing options object | ||
test('test db open and use, level(location, options, cb) force error', function (t) { | ||
level(location, { errorIfExists: true }, function (err, db) { | ||
t.ok(err, 'got error opening existing db') | ||
t.notOk(db, 'no db') | ||
t.end() | ||
}) | ||
}) | ||
} | ||
test('test db open and use, db=level(location)', function (t) { | ||
var db = level(location) | ||
db.put('test3', 'success', function (err) { | ||
t.notOk(err, 'no error') | ||
db.close(t.end.bind(t)) | ||
}) | ||
}) | ||
test('test db values', function (t) { | ||
let c = 0 | ||
var db = level(location) | ||
var setup = options.nonPersistent ? function (callback) { | ||
db.batch([ | ||
{ type: 'put', key: 'test1', value: 'success' }, | ||
{ type: 'put', key: 'test2', value: 'success' }, | ||
{ type: 'put', key: 'test3', value: 'success' } | ||
], callback) | ||
} : function (callback) { callback() } | ||
function read (err, value) { | ||
t.notOk(err, 'no error') | ||
t.equal(value, 'success') | ||
if (++c === 3) { db.close(t.end.bind(t)) } | ||
} | ||
setup(function (err) { | ||
t.notOk(err, 'no error') | ||
db.get('test1', read) | ||
db.get('test2', read) | ||
db.get('test3', read) | ||
}) | ||
}) | ||
test('options.keyEncoding and options.valueEncoding are passed on to encoding-down', function (t) { | ||
var db = level(location, { keyEncoding: 'json', valueEncoding: 'json' }) | ||
db.on('ready', function () { | ||
var codec = db.db.codec | ||
t.equal(codec.opts.keyEncoding, 'json', 'keyEncoding correct') | ||
t.equal(codec.opts.valueEncoding, 'json', 'valueEncoding correct') | ||
db.close(t.end.bind(t)) | ||
}) | ||
}) | ||
test('encoding options default to utf8', function (t) { | ||
var db = level(location) | ||
db.on('ready', function () { | ||
var codec = db.db.codec | ||
t.equal(codec.opts.keyEncoding, 'utf8', 'keyEncoding correct') | ||
t.equal(codec.opts.valueEncoding, 'utf8', 'valueEncoding correct') | ||
db.close(t.end.bind(t)) | ||
}) | ||
}) | ||
if (!options.skipRepairTest) { | ||
test('test repair', function (t) { | ||
t.plan(1) | ||
level.repair(location, function (err) { | ||
t.notOk(err, 'no error') | ||
}) | ||
}) | ||
} | ||
if (!options.skipDestroyTest) { | ||
test('test destroy', function (t) { | ||
t.plan(4) | ||
t.ok(fs.statSync(location).isDirectory(), 'sanity check, directory exists') | ||
t.ok(fs.existsSync(path.join(location, 'LOG')), 'sanity check, log exists') | ||
level.destroy(location, function (err) { | ||
t.notOk(err, 'no error') | ||
t.notOk(fs.existsSync(path.join(location, 'LOG')), 'db gone (mostly)') | ||
}) | ||
}) | ||
} | ||
} | ||
if (!module.parent) { | ||
@@ -122,0 +6,0 @@ var test = require('tape') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15
156
18504
1