[Pkg-javascript-commits] [node-leveldown] 228/492: added batch tests
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:14:02 UTC 2014
This is an automated email from the git hooks/post-receive script.
andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.
commit 2abf30a37c5bc2285f27657165395d9c88bf3336
Author: Rod Vagg <rod at vagg.org>
Date: Sat Feb 23 14:21:33 2013 +1100
added batch tests
---
test/batch-test.js | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 82 insertions(+)
diff --git a/test/batch-test.js b/test/batch-test.js
new file mode 100644
index 0000000..29dc189
--- /dev/null
+++ b/test/batch-test.js
@@ -0,0 +1,82 @@
+const test = require('tap').test
+ , testCommon = require('./common')
+ , leveldown = require('../')
+
+var db
+
+test('setUp', function (t) {
+ db = leveldown(testCommon.location())
+ db.open(testCommon.setUp.bind(null, t))
+})
+
+test('test argument-less batch() throws', function (t) {
+ t.throws(db.batch.bind(db), 'no-arg batch() throws')
+ t.end()
+})
+
+test('test callback-less, 1-arg, batch() throws', function (t) {
+ t.throws(db.batch.bind(db, []), 'callback-less, 1-arg batch() throws')
+ t.end()
+})
+
+test('test callback-less, 3-arg, batch() throws', function (t) {
+ t.throws(db.batch.bind(db, [], {}), 'callback-less, 3-arg batch() throws')
+ t.end()
+})
+
+test('test batch() with wrong arg throws', function (t) {
+ t.throws(db.batch.bind(db, {}, {}), 'wrong arg type 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.notOk(err, 'no error')
+
+ db.get('foo1', function (err, value) {
+ t.ok(err, 'entry not found')
+ t.notOk(value, 'value not returned')
+ t.like(err.message, /NotFound/)
+ t.end()
+ })
+ })
+})
+
+test('test batch() with missing `key`', function (t) {
+ db.batch([{ type: 'put', value: 'foo1' }], function (err) {
+ t.notOk(err, 'no error')
+ t.end()
+ })
+})
+
+test('test batch() with missing `key` and `value`', function (t) {
+ db.batch([{ type: 'put' }], function (err) {
+ t.notOk(err, 'no error')
+ t.end()
+ })
+})
+
+test('tearDown', function (t) {
+ db.close(testCommon.tearDown.bind(null, t))
+})
\ 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