[Pkg-javascript-commits] [node-leveldown] 01/02: update tests, abstract-leveldown has batch* tests
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:17:08 UTC 2014
This is an automated email from the git hooks/post-receive script.
andrewrk-guest pushed a commit to tag 0.2.2
in repository node-leveldown.
commit 784000d78b28a32e6d7a56080b6fc6f88a437ffa
Author: Rod Vagg <rod at vagg.org>
Date: Tue May 14 20:10:28 2013 +1000
update tests, abstract-leveldown has batch* tests
---
src/batch.cc | 2 +-
test/approximate-size-test.js | 2 +-
test/batch-test.js | 113 ++----------------------------------------
test/chained-batch-test.js | 47 ++----------------
test/close-test.js | 2 +-
test/del-test.js | 2 +-
test/get-test.js | 2 +-
test/iterator-test.js | 2 +-
test/leveldown-test.js | 2 +-
test/make-test.js | 16 +++---
test/open-test.js | 2 +-
test/put-get-del-test.js | 6 +--
test/put-test.js | 2 +-
13 files changed, 27 insertions(+), 173 deletions(-)
diff --git a/src/batch.cc b/src/batch.cc
index 4b8448e..0436599 100644
--- a/src/batch.cc
+++ b/src/batch.cc
@@ -157,7 +157,7 @@ v8::Handle<v8::Value> Batch::Write (const v8::Arguments& args) {
Batch* batch = ObjectWrap::Unwrap<Batch>(args.Holder());
if (args.Length() == 0) {
- LD_THROW_RETURN(name() requires a callback argument)
+ LD_THROW_RETURN(write() requires a callback argument)
}
v8::Persistent<v8::Function> callback = v8::Persistent<v8::Function>::New(
LD_NODE_ISOLATE_PRE
diff --git a/test/approximate-size-test.js b/test/approximate-size-test.js
index d9ec813..788d10e 100644
--- a/test/approximate-size-test.js
+++ b/test/approximate-size-test.js
@@ -1,7 +1,7 @@
const test = require('tap').test
, testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
- , abstract = require('abstract-leveldown/abstract/approximate-size-test')
+ , abstract = require('abstract-leveldown/abstract/approximate-size-test')
if (require.main === module)
abstract.all(leveldown, test, testCommon)
\ No newline at end of file
diff --git a/test/batch-test.js b/test/batch-test.js
index fd2c88e..4040eea 100644
--- a/test/batch-test.js
+++ b/test/batch-test.js
@@ -1,114 +1,7 @@
const test = require('tap').test
, testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
+ , abstract = require('abstract-leveldown/abstract/batch-test')
-var db
-
-test('setUp common', testCommon.setUp)
-test('setUp db', function (t) {
- db = leveldown(testCommon.location())
- db.open(t.end.bind(t))
-})
-
-test('test callback-less, 2-arg, batch() throws', function (t) {
- t.throws(db.batch.bind(db, 'foo', {}), 'callback-less, 2-arg batch() throws')
- t.end()
-})
-
-test('test batch() with empty array', function (t) {
- db.batch([], function (err) {
- t.notOk(err, 'no error')
- t.end()
- })
-})
-
-test('test simple batch()', function (t) {
- db.batch([{ type: 'put', key: 'foo', value: 'bar' }], function (err) {
- t.notOk(err, 'no error')
-
- db.get('foo', function (err, value) {
- t.notOk(err, 'no error')
- t.type(value, Buffer)
- t.equal(value.toString(), 'bar')
-
- t.end()
- })
- })
-})
-
-test('test batch() with missing `value`', function (t) {
- db.batch([{ type: 'put', key: 'foo1' }], function (err) {
- t.like(err.message, /value cannot be `null` or `undefined`/, 'correct error message')
- t.end()
- })
-})
-
-test('test batch() with null `value`', function (t) {
- db.batch([{ type: 'put', key: 'foo1', value: null }], function (err) {
- t.like(err.message, /value cannot be `null` or `undefined`/, 'correct error message')
- t.end()
- })
-})
-
-test('test batch() with missing `key`', function (t) {
- db.batch([{ type: 'put', value: 'foo1' }], function (err) {
- t.like(err.message, /key cannot be `null` or `undefined`/, 'correct error message')
- t.end()
- })
-})
-
-test('test batch() with null `key`', function (t) {
- db.batch([{ type: 'put', key: null, value: 'foo1' }], function (err) {
- t.like(err.message, /key cannot be `null` or `undefined`/, 'correct error message')
- t.end()
- })
-})
-
-test('test batch() with missing `key` and `value`', function (t) {
- db.batch([{ type: 'put' }], function (err) {
- t.like(err.message, /key cannot be `null` or `undefined`/, 'correct error message')
- t.end()
- })
-})
-
-test('test multiple batch()', function (t) {
- db.batch([
- { type: 'put', key: 'foobatch1', value: 'bar1' }
- , { type: 'put', key: 'foobatch2', value: 'bar2' }
- , { type: 'put', key: 'foobatch3', value: 'bar3' }
- , { type: 'del', key: 'foobatch2' }
- ], function (err) {
- t.notOk(err, 'no error')
-
- var r = 0
- , done = function () {
- if (++r == 3)
- t.end()
- }
-
- db.get('foobatch1', function (err, value) {
- t.notOk(err, 'no error')
- t.type(value, Buffer)
- t.equal(value.toString(), 'bar1')
- done()
- })
-
- db.get('foobatch2', function (err, value) {
- t.ok(err, 'entry not found')
- t.notOk(value, 'value not returned')
- t.like(err.message, /NotFound/)
- done()
- })
-
- db.get('foobatch3', function (err, value) {
- t.notOk(err, 'no error')
- t.type(value, Buffer)
- t.equal(value.toString(), 'bar3')
- done()
- })
- })
-})
-
-test('tearDown', function (t) {
- db.close(testCommon.tearDown.bind(null, t))
-})
\ No newline at end of file
+if (require.main === module)
+ abstract.all(leveldown, test, testCommon)
\ No newline at end of file
diff --git a/test/chained-batch-test.js b/test/chained-batch-test.js
index d7fdb72..562f868 100644
--- a/test/chained-batch-test.js
+++ b/test/chained-batch-test.js
@@ -1,48 +1,7 @@
const test = require('tap').test
, testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
+ , abstract = require('abstract-leveldown/abstract/chained-batch-test')
-var db
-
-test('setUp common', testCommon.setUp)
-test('setUp db', function (t) {
- db = leveldown(testCommon.location())
- db.open(t.end.bind(t))
-})
-
-test('basic batch', function (t) {
- db.batch(
- [
- { type: 'put', key: 'one', value: '1' }
- , { type: 'put', key: 'two', value: '2' }
- , { type: 'put', key: 'three', value: '3' }
- ]
- , function (err) {
- t.notOk(err, 'no error')
-
- db.batch()
- .put('one', 'I')
- .put('two', 'II')
- .del('three')
- .put('foo', 'bar')
- .write(function (err) {
- t.notOk(err, 'no error')
- testCommon.collectEntries(db.iterator({ keyAsBuffer: false, valueAsBuffer: false }), function (err, data) {
- t.notOk(err, 'no error')
- t.equal(data.length, 3, 'correct number of entries')
- var expected = [
- { key: 'foo', value: 'bar' }
- , { key: 'one', value: 'I' }
- , { key: 'two', value: 'II' }
- ]
- t.deepEqual(data, expected)
- t.end()
- })
- })
- }
- )
-})
-
-test('tearDown', function (t) {
- db.close(testCommon.tearDown.bind(null, t))
-})
\ No newline at end of file
+if (require.main === module)
+ abstract.all(leveldown, test, testCommon)
\ No newline at end of file
diff --git a/test/close-test.js b/test/close-test.js
index a44ae31..3b9f9e7 100644
--- a/test/close-test.js
+++ b/test/close-test.js
@@ -1,7 +1,7 @@
const test = require('tap').test
, testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
- , abstract = require('abstract-leveldown/abstract/close-test')
+ , abstract = require('abstract-leveldown/abstract/close-test')
module.exports.setUp = function () {
test('setUp', testCommon.setUp)
diff --git a/test/del-test.js b/test/del-test.js
index bc5b73e..f1b12c9 100644
--- a/test/del-test.js
+++ b/test/del-test.js
@@ -1,7 +1,7 @@
const test = require('tap').test
, testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
- , abstract = require('abstract-leveldown/abstract/del-test')
+ , abstract = require('abstract-leveldown/abstract/del-test')
if (require.main === module)
abstract.all(leveldown, test, testCommon)
\ No newline at end of file
diff --git a/test/get-test.js b/test/get-test.js
index 1080fd9..5423ea1 100644
--- a/test/get-test.js
+++ b/test/get-test.js
@@ -1,7 +1,7 @@
const test = require('tap').test
, testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
- , abstract = require('abstract-leveldown/abstract/get-test')
+ , abstract = require('abstract-leveldown/abstract/get-test')
if (require.main === module)
abstract.all(leveldown, test, testCommon)
\ No newline at end of file
diff --git a/test/iterator-test.js b/test/iterator-test.js
index 8ff8c4a..18073f6 100644
--- a/test/iterator-test.js
+++ b/test/iterator-test.js
@@ -1,7 +1,7 @@
const test = require('tap').test
, testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
- , abstract = require('abstract-leveldown/abstract/iterator-test')
+ , abstract = require('abstract-leveldown/abstract/iterator-test')
if (require.main === module)
abstract.all(leveldown, test, testCommon)
\ No newline at end of file
diff --git a/test/leveldown-test.js b/test/leveldown-test.js
index fc531c8..d65e078 100644
--- a/test/leveldown-test.js
+++ b/test/leveldown-test.js
@@ -1,6 +1,6 @@
const test = require('tap').test
, leveldown = require('../')
- , abstract = require('abstract-leveldown/abstract/leveldown-test')
+ , abstract = require('abstract-leveldown/abstract/leveldown-test')
if (require.main === module)
abstract.args(leveldown, test)
\ No newline at end of file
diff --git a/test/make-test.js b/test/make-test.js
index d8a8d8f..167027d 100644
--- a/test/make-test.js
+++ b/test/make-test.js
@@ -1,10 +1,10 @@
-var test = require('tap').test
-var testCommon = require('abstract-leveldown/testCommon')
-var cleanup = testCommon.cleanup
-var location = testCommon.location
-var leveldown = require('../')
+const test = require('tap').test
+ , testCommon = require('abstract-leveldown/testCommon')
+ , cleanup = testCommon.cleanup
+ , location = testCommon.location
+ , leveldown = require('../')
-module.exports = function (name, testFn) {
+function makeTest (name, testFn) {
test(name, function (t) {
cleanup(function () {
var loc = location()
@@ -33,4 +33,6 @@ module.exports = function (name, testFn) {
})
})
})
-}
\ No newline at end of file
+}
+
+module.exports = makeTest
\ No newline at end of file
diff --git a/test/open-test.js b/test/open-test.js
index 2028a73..4d84996 100644
--- a/test/open-test.js
+++ b/test/open-test.js
@@ -1,7 +1,7 @@
const test = require('tap').test
, testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
- , abstract = require('abstract-leveldown/abstract/open-test')
+ , abstract = require('abstract-leveldown/abstract/open-test')
if (require.main === module)
abstract.all(leveldown, test, testCommon)
\ No newline at end of file
diff --git a/test/put-get-del-test.js b/test/put-get-del-test.js
index 6760a73..631d886 100644
--- a/test/put-get-del-test.js
+++ b/test/put-get-del-test.js
@@ -1,10 +1,10 @@
const test = require('tap').test
, testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
- , fs = require('fs')
- , path = require('path')
+ , 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 = require('abstract-leveldown/abstract/put-get-del-test')
if (require.main === module)
abstract.all(leveldown, test, testCommon, testBuffer)
diff --git a/test/put-test.js b/test/put-test.js
index 07394d4..f24997f 100644
--- a/test/put-test.js
+++ b/test/put-test.js
@@ -1,7 +1,7 @@
const test = require('tap').test
, testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
- , abstract = require('abstract-leveldown/abstract/put-test')
+ , abstract = require('abstract-leveldown/abstract/put-test')
if (require.main === module)
abstract.all(leveldown, test, testCommon)
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git
More information about the Pkg-javascript-commits
mailing list