Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
Temporarily relax error tests for abstract-leveldown
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed Oct 9, 2021
1 parent 15ea858 commit 9a18729
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
33 changes: 18 additions & 15 deletions test/batch-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const levelup = require('../lib/levelup')
const errors = levelup.errors
'use strict'

// const levelup = require('../lib/levelup')
// const errors = levelup.errors
const each = require('async-each')
const series = require('run-series')
const discardable = require('./util/discardable')
const verifyNotFoundError = require('./util/verify-not-found-error')

module.exports = function (test, testCommon) {
test('array-form batch(): multiple puts', function (t) {
Expand Down Expand Up @@ -79,7 +82,7 @@ module.exports = function (test, testCommon) {
each(['1', 'foo'], function (key, next) {
db.get(key, { asBuffer: false }, function (err, value) {
t.ok(err)
t.ok(err instanceof errors.NotFoundError)
t.ok(verifyNotFoundError(err))
t.is(value, undefined)
next()
})
Expand Down Expand Up @@ -243,7 +246,7 @@ module.exports = function (test, testCommon) {
each(['1', 'foo'], function (key, next) {
db.get(key, { asBuffer: false }, function (err, value) {
t.ok(err)
t.ok(err instanceof errors.NotFoundError)
t.ok(verifyNotFoundError(err))
t.is(value, undefined)
next()
})
Expand Down Expand Up @@ -278,7 +281,7 @@ module.exports = function (test, testCommon) {
// this shouldn't exist
db.get('1', { asBuffer: false }, function (err, value) {
t.ok(err)
t.ok(err instanceof errors.NotFoundError)
t.ok(verifyNotFoundError(err))
t.is(value, undefined)
next()
})
Expand All @@ -293,12 +296,12 @@ module.exports = function (test, testCommon) {

t.test('chained batch() arguments: batch#put() with missing `value`', function (t) {
throws(t, batch.put.bind(batch, 'foo1'), function (err) {
t.is(err.name, 'WriteError')
// t.is(err.name, 'WriteError') // https://github.com/Level/errors/issues/39
t.is(err.message, 'value cannot be `null` or `undefined`')
})

throws(t, batch.put.bind(batch, 'foo1', null), function (err) {
t.is(err.name, 'WriteError')
// t.is(err.name, 'WriteError') // https://github.com/Level/errors/issues/39
t.is(err.message, 'value cannot be `null` or `undefined`')
})

Expand All @@ -307,12 +310,12 @@ module.exports = function (test, testCommon) {

t.test('chained batch() arguments: batch#put() with missing `key`', function (t) {
throws(t, batch.put.bind(batch, undefined, 'foo1'), function (err) {
t.is(err.name, 'WriteError')
// t.is(err.name, 'WriteError') // https://github.com/Level/errors/issues/39
t.is(err.message, 'key cannot be `null` or `undefined`')
})

throws(t, batch.put.bind(batch, null, 'foo1'), function (err) {
t.is(err.name, 'WriteError')
// t.is(err.name, 'WriteError') // https://github.com/Level/errors/issues/39
t.is(err.message, 'key cannot be `null` or `undefined`')
})

Expand All @@ -321,12 +324,12 @@ module.exports = function (test, testCommon) {

t.test('chained batch() arguments: batch#put() with missing `key` and `value`', function (t) {
throws(t, batch.put.bind(batch), function (err) {
t.is(err.name, 'WriteError')
// t.is(err.name, 'WriteError') // https://github.com/Level/errors/issues/39
t.is(err.message, 'key cannot be `null` or `undefined`')
})

throws(t, batch.put.bind(batch, null, null), function (err) {
t.is(err.name, 'WriteError')
// t.is(err.name, 'WriteError') // https://github.com/Level/errors/issues/39
t.is(err.message, 'key cannot be `null` or `undefined`')
})

Expand All @@ -335,12 +338,12 @@ module.exports = function (test, testCommon) {

t.test('chained batch() arguments: batch#del() with missing `key`', function (t) {
throws(t, batch.del.bind(batch, undefined, 'foo1'), function (err) {
t.is(err.name, 'WriteError')
// t.is(err.name, 'WriteError') // https://github.com/Level/errors/issues/39
t.is(err.message, 'key cannot be `null` or `undefined`')
})

throws(t, batch.del.bind(batch, null, 'foo1'), function (err) {
t.is(err.name, 'WriteError')
// t.is(err.name, 'WriteError') // https://github.com/Level/errors/issues/39
t.is(err.message, 'key cannot be `null` or `undefined`')
})

Expand All @@ -357,8 +360,8 @@ module.exports = function (test, testCommon) {
test('chained batch(): rejects operations after write()', function (t) {
discardable(t, testCommon, function (db, done) {
function verify (err) {
t.is(err.name, 'WriteError')
t.is(err.message, 'write() already called on this batch')
// t.is(err.name, 'WriteError') // https://github.com/Level/errors/issues/39
t.ok(err)
}

const batch = db.batch()
Expand Down
31 changes: 20 additions & 11 deletions test/get-put-del-test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
const errors = require('../lib/levelup').errors
'use strict'

// const errors = require('../lib/levelup').errors
const each = require('async-each')
const series = require('run-series')
const discardable = require('./util/discardable')
const verifyNotFoundError = require('./util/verify-not-found-error')

module.exports = function (test, testCommon) {
test('get() / put() / del(): get() on empty database causes error', function (t) {
discardable(t, testCommon, function (db, done) {
db.get('undefkey', function (err, value) {
t.notOk(value)
t.ok(err instanceof Error)
t.ok(err instanceof errors.LevelUPError)
t.ok(err instanceof errors.NotFoundError)
t.is(err.notFound, true, 'err.notFound is `true`')
t.is(err.status, 404, 'err.status is 404')
t.ok(/\[undefkey\]/.test(err))
t.ok(verifyNotFoundError(err))

// https://github.com/Level/errors/issues/39
// t.ok(err instanceof errors.LevelUPError)
// t.is(err.notFound, true, 'err.notFound is `true`')
// t.is(err.status, 404, 'err.status is 404')
// t.ok(/\[undefkey\]/.test(err))

done()
})
})
Expand All @@ -23,11 +29,14 @@ module.exports = function (test, testCommon) {
discardable(t, testCommon, function (db, done) {
db.get('undefkey').catch(function (err) {
t.ok(err instanceof Error)
t.ok(err instanceof errors.LevelUPError)
t.ok(err instanceof errors.NotFoundError)
t.is(err.notFound, true, 'err.notFound is `true`')
t.is(err.status, 404, 'err.status is 404')
t.ok(/\[undefkey\]/.test(err))
t.ok(verifyNotFoundError(err))

// https://github.com/Level/errors/issues/39
// t.ok(err instanceof errors.LevelUPError)
// t.is(err.notFound, true, 'err.notFound is `true`')
// t.is(err.status, 404, 'err.status is 404')
// t.ok(/\[undefkey\]/.test(err))

done()
})
})
Expand Down

0 comments on commit 9a18729

Please sign in to comment.