abstract-leveldown
Advanced tools
Comparing version 0.10.1 to 0.10.2
var db | ||
, verifyNotFoundError = require('./util').verifyNotFoundError | ||
, isTypedArray = require('./util').isTypedArray | ||
function isTypedArray (value) { | ||
return value instanceof ArrayBuffer || value instanceof Uint8Array | ||
} | ||
module.exports.setUp = function (leveldown, test, testCommon) { | ||
@@ -114,4 +112,4 @@ test('setUp common', testCommon.setUp) | ||
t.ok(err, 'entry not found') | ||
t.notOk(value, 'value not returned') | ||
t.ok((/NotFound/i).test(err.message), 'NotFound error') | ||
t.ok(typeof value == 'undefined', 'value is undefined') | ||
t.ok(verifyNotFoundError(err), 'NotFound error') | ||
done() | ||
@@ -118,0 +116,0 @@ }) |
var db | ||
, verifyNotFoundError = require('./util').verifyNotFoundError | ||
, isTypedArray = require('./util').isTypedArray | ||
@@ -48,8 +50,6 @@ module.exports.setUp = function (leveldown, test, testCommon) { | ||
t.ok(err, 'entry propertly deleted') | ||
var message = "" | ||
if (err) message = err.message | ||
t.ok(message.match(/NotFound/i), 'returned NotFound') | ||
t.ok(typeof value == 'undefined', 'value is undefined') | ||
t.ok(verifyNotFoundError(err), 'NotFound error') | ||
t.end() | ||
}) | ||
}) | ||
@@ -56,0 +56,0 @@ }) |
var db | ||
, verifyNotFoundError = require('./util').verifyNotFoundError | ||
, isTypedArray = require('./util').isTypedArray | ||
function isTypedArray (value) { | ||
return value instanceof ArrayBuffer || value instanceof Uint8Array | ||
} | ||
module.exports.setUp = function (leveldown, test, testCommon) { | ||
@@ -89,2 +87,3 @@ test('setUp common', testCommon.setUp) | ||
db.put('hello', 'world', function (err) { | ||
t.notOk(err, 'should not error') | ||
var r = 0 | ||
@@ -108,3 +107,4 @@ , done = function () { | ||
t.ok(err, 'should error') | ||
t.ok((/NotFound: /i).test(err.message), 'should have correct error message') | ||
t.ok(verifyNotFoundError(err), 'should have correct error message') | ||
t.ok(typeof value == 'undefined', 'value is undefined') | ||
done() | ||
@@ -111,0 +111,0 @@ }) |
/**** SETUP & UTILITY STUFF ****/ | ||
function isTypedArray (value) { | ||
return value instanceof ArrayBuffer || value instanceof Uint8Array | ||
} | ||
@@ -10,72 +7,76 @@ var db | ||
, test | ||
, makeGetDelErrorTests = function (type, key, expectedError) { | ||
test('test get() with ' + type + ' causes error', function (t) { | ||
db.get(key, function (err) { | ||
t.ok(err, 'has error') | ||
t.ok(err instanceof Error) | ||
t.ok(err.message.match(expectedError), 'correct error message') | ||
t.end() | ||
}) | ||
}) | ||
, verifyNotFoundError = require('./util').verifyNotFoundError | ||
, isTypedArray = require('./util').isTypedArray | ||
test('test del() with ' + type + ' causes error', function (t) { | ||
db.del(key, function (err) { | ||
t.ok(err, 'has error') | ||
t.ok(err instanceof Error) | ||
t.ok(err.message.match(expectedError), 'correct error message') | ||
t.end() | ||
}) | ||
}) | ||
} | ||
function makeGetDelErrorTests (type, key, expectedError) { | ||
test('test get() with ' + type + ' causes error', function (t) { | ||
db.get(key, function (err) { | ||
t.ok(err, 'has error') | ||
t.ok(err instanceof Error) | ||
t.ok(err.message.match(expectedError), 'correct error message') | ||
t.end() | ||
}) | ||
}) | ||
, makePutErrorTest = function (type, key, value, expectedError) { | ||
test('test put() with ' + type + ' causes error', function (t) { | ||
db.put(key, value, function (err) { | ||
t.ok(err, 'has error') | ||
t.ok(err instanceof Error) | ||
t.ok(err.message.match(expectedError), 'correct error message') | ||
t.end() | ||
}) | ||
}) | ||
} | ||
test('test del() with ' + type + ' causes error', function (t) { | ||
db.del(key, function (err) { | ||
t.ok(err, 'has error') | ||
t.ok(err instanceof Error) | ||
t.ok(err.message.match(expectedError), 'correct error message') | ||
t.end() | ||
}) | ||
}) | ||
} | ||
, makePutGetDelSuccessfulTest = function (type, key, value) { | ||
test('test put()/get()/del() with ' + type, function (t) { | ||
db.put(key, value, function (err) { | ||
t.notOk(err, 'no error') | ||
db.get(key, function (err, _value) { | ||
t.notOk(err, 'no error, has key/value for `' + key + '`') | ||
function makePutErrorTest (type, key, value, expectedError) { | ||
test('test put() with ' + type + ' causes error', function (t) { | ||
db.put(key, value, function (err) { | ||
t.ok(err, 'has error') | ||
t.ok(err instanceof Error) | ||
t.ok(err.message.match(expectedError), 'correct error message') | ||
t.end() | ||
}) | ||
}) | ||
} | ||
var result, valueString | ||
if (isTypedArray(_value)) { | ||
result = String.fromCharCode.apply(null, new Uint16Array(_value)) | ||
} else { | ||
t.ok(typeof Buffer != 'undefined' && _value instanceof Buffer, 'is a Buffer') | ||
result = _value.toString() | ||
} | ||
if (isTypedArray(value)) { | ||
value = String.fromCharCode.apply(null, new Uint16Array(value)) | ||
} else { | ||
value = value.toString() | ||
} | ||
t.equals(result, value) | ||
db.del(key, function (err) { | ||
t.notOk(err, 'no error, deleted key/value for `' + key + '`') | ||
db.get(key, function (err) { | ||
t.ok(err, 'entry propertly deleted') | ||
t.ok(err.message.match(/NotFound/i), 'is NotFound') | ||
t.end() | ||
}) | ||
}) | ||
function makePutGetDelSuccessfulTest (type, key, value) { | ||
test('test put()/get()/del() with ' + type, function (t) { | ||
db.put(key, value, function (err) { | ||
t.notOk(err, 'no error') | ||
db.get(key, function (err, _value) { | ||
t.notOk(err, 'no error, has key/value for `' + key + '`') | ||
var result | ||
if (isTypedArray(_value)) { | ||
result = String.fromCharCode.apply(null, new Uint16Array(_value)) | ||
} else { | ||
t.ok(typeof Buffer != 'undefined' && _value instanceof Buffer, 'is a Buffer') | ||
result = _value.toString() | ||
} | ||
if (isTypedArray(value)) { | ||
value = String.fromCharCode.apply(null, new Uint16Array(value)) | ||
} else { | ||
value = value.toString() | ||
} | ||
t.equals(result, value) | ||
db.del(key, function (err) { | ||
t.notOk(err, 'no error, deleted key/value for `' + key + '`') | ||
db.get(key, function (err, value) { | ||
t.ok(err, 'entry propertly deleted') | ||
t.ok(verifyNotFoundError(err), 'should have correct error message') | ||
t.ok(typeof value == 'undefined', 'value is undefined') | ||
t.end() | ||
}) | ||
}) | ||
}) | ||
} | ||
}) | ||
}) | ||
} | ||
, makeErrorKeyTest = function (type, key, expectedError) { | ||
makeGetDelErrorTests(type, key, expectedError) | ||
makePutErrorTest(type, key, 'foo', expectedError) | ||
} | ||
function makeErrorKeyTest (type, key, expectedError) { | ||
makeGetDelErrorTests(type, key, expectedError) | ||
makePutErrorTest(type, key, 'foo', expectedError) | ||
} | ||
@@ -82,0 +83,0 @@ /**** SETUP ENVIRONMENT ****/ |
var db | ||
, verifyNotFoundError = require('./util').verifyNotFoundError | ||
, isTypedArray = require('./util').isTypedArray | ||
function isTypedArray (value) { | ||
return value instanceof ArrayBuffer || value instanceof Uint8Array | ||
} | ||
module.exports.setUp = function (leveldown, test, testCommon) { | ||
@@ -8,0 +6,0 @@ test('setUp common', testCommon.setUp) |
@@ -0,4 +1,9 @@ | ||
### 0.10.2 - Sep 6 2013 | ||
* Refactor duplicated versions of isTypedArray into util.js (@rvagg) | ||
* Refactor duplicated versions of 'NotFound' checks into util.js, fixed too-strict version in get-test.js (@rvagg) | ||
### 0.10.1 - Aug 29 2013 | ||
* Relax check for 'Not Found: ' in error message to be case insensitive in get-test.js | ||
* Relax check for 'Not Found: ' in error message to be case insensitive in get-test.js (@rvagg) | ||
@@ -5,0 +10,0 @@ ### 0.10.0 - Aug 19 2013 |
{ | ||
"name" : "abstract-leveldown" | ||
, "description" : "An abstract prototype matching the LevelDOWN API" | ||
, "version" : "0.10.1" | ||
, "version" : "0.10.2" | ||
, "contributors" : [ | ||
@@ -6,0 +6,0 @@ "Rod Vagg <r@va.gg> (https://github.com/rvagg)" |
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
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
111105
26
2511