[Pkg-javascript-commits] [node-leveldown] 312/492: move testCommon into abstract-leveldown and make-test.js
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:14:12 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 ad28767542823ab79eadc9116ed946337fb7c928
Author: Max Ogden <max at maxogden.com>
Date: Mon Apr 22 21:25:55 2013 -0700
move testCommon into abstract-leveldown and make-test.js
---
test/approximate-size-test.js | 2 +-
test/batch-test.js | 2 +-
test/chained-batch-test.js | 2 +-
test/cleanup-hanging-iterators-test.js | 4 +-
test/close-test.js | 2 +-
test/common.js | 107 ---------------------------------
test/del-test.js | 2 +-
test/destroy-test.js | 4 +-
test/get-test.js | 2 +-
test/iterator-test.js | 2 +-
test/make-test.js | 36 +++++++++++
test/open-test.js | 2 +-
test/put-get-del-test.js | 2 +-
test/put-test.js | 2 +-
test/repair-test.js | 4 +-
15 files changed, 52 insertions(+), 123 deletions(-)
diff --git a/test/approximate-size-test.js b/test/approximate-size-test.js
index 2b22875..d9ec813 100644
--- a/test/approximate-size-test.js
+++ b/test/approximate-size-test.js
@@ -1,5 +1,5 @@
const test = require('tap').test
- , testCommon = require('./common')
+ , testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
, abstract = require('abstract-leveldown/abstract/approximate-size-test')
diff --git a/test/batch-test.js b/test/batch-test.js
index 1517bac..fd2c88e 100644
--- a/test/batch-test.js
+++ b/test/batch-test.js
@@ -1,5 +1,5 @@
const test = require('tap').test
- , testCommon = require('./common')
+ , testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
var db
diff --git a/test/chained-batch-test.js b/test/chained-batch-test.js
index 9641c74..d7fdb72 100644
--- a/test/chained-batch-test.js
+++ b/test/chained-batch-test.js
@@ -1,5 +1,5 @@
const test = require('tap').test
- , testCommon = require('./common')
+ , testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
var db
diff --git a/test/cleanup-hanging-iterators-test.js b/test/cleanup-hanging-iterators-test.js
index 6ad9dda..f811b7d 100644
--- a/test/cleanup-hanging-iterators-test.js
+++ b/test/cleanup-hanging-iterators-test.js
@@ -1,7 +1,7 @@
const test = require('tap').test
- , testCommon = require('./common')
+ , testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
- , makeTest = testCommon.makeExistingDbTest
+ , makeTest = require('./make-test')
makeTest('test ended iterator', function (db, t, done) {
// standard iterator with an end() properly called, easy
diff --git a/test/close-test.js b/test/close-test.js
index eb2be94..a44ae31 100644
--- a/test/close-test.js
+++ b/test/close-test.js
@@ -1,5 +1,5 @@
const test = require('tap').test
- , testCommon = require('./common')
+ , testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
, abstract = require('abstract-leveldown/abstract/close-test')
diff --git a/test/common.js b/test/common.js
deleted file mode 100644
index de8d7ba..0000000
--- a/test/common.js
+++ /dev/null
@@ -1,107 +0,0 @@
-const path = require('path')
- , fs = require('fs')
- , rimraf = require('rimraf')
- , test = require('tap').test
- , leveldown = require('../')
-
-var dbidx = 0
-
- , location = function () {
- return path.join(__dirname, '_leveldown_test_db_' + dbidx++)
- }
-
- , lastLocation = function () {
- return path.join(__dirname, '_leveldown_test_db_' + dbidx)
- }
-
- , cleanup = function (callback) {
- fs.readdir(__dirname, function (err, list) {
- if (err) return callback(err)
-
- list = list.filter(function (f) {
- return (/^_leveldown_test_db_/).test(f)
- })
-
- if (!list.length)
- return callback()
-
- var ret = 0
-
- list.forEach(function (f) {
- rimraf(path.join(__dirname, f), function (err) {
- if (++ret == list.length)
- callback()
- })
- })
- })
- }
-
- , setUp = function (t) {
- cleanup(function (err) {
- t.notOk(err, 'cleanup returned an error')
- t.end()
- })
- }
-
- , tearDown = function (t) {
- setUp(t) // same cleanup!
- }
-
- , collectEntries = function (iterator, callback) {
- var data = []
- , next = function () {
- iterator.next(function (err, key, value) {
- if (err) return callback(err)
- if (!arguments.length) {
- return iterator.end(function (err) {
- callback(err, data)
- })
- }
- if (key == +key) key = +key
- data.push({ key: key, value: value })
- process.nextTick(next)
- })
- }
- next()
- }
-
- , makeExistingDbTest = function (name, testFn) {
- test(name, function (t) {
- cleanup(function () {
- var loc = location()
- , db = leveldown(loc)
- , done = function (close) {
- if (close === false)
- return cleanup(t.end.bind(t))
- db.close(function (err) {
- t.notOk(err, 'no error from close()')
- cleanup(t.end.bind(t))
- })
- }
- db.open(function (err) {
- t.notOk(err, 'no error from open()')
- 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 from batch()')
- testFn(db, t, done, loc)
- }
- )
- })
- })
- })
- }
-
-module.exports = {
- location : location
- , cleanup : cleanup
- , lastLocation : lastLocation
- , setUp : setUp
- , tearDown : tearDown
- , collectEntries : collectEntries
- , makeExistingDbTest : makeExistingDbTest
-}
diff --git a/test/del-test.js b/test/del-test.js
index 16789b8..bc5b73e 100644
--- a/test/del-test.js
+++ b/test/del-test.js
@@ -1,5 +1,5 @@
const test = require('tap').test
- , testCommon = require('./common')
+ , testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
, abstract = require('abstract-leveldown/abstract/del-test')
diff --git a/test/destroy-test.js b/test/destroy-test.js
index 79a0baf..aa97053 100644
--- a/test/destroy-test.js
+++ b/test/destroy-test.js
@@ -3,9 +3,9 @@ const test = require('tap').test
, path = require('path')
, mkfiletree = require('mkfiletree')
, readfiletree = require('readfiletree')
- , testCommon = require('./common')
+ , testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
- , makeTest = testCommon.makeExistingDbTest
+ , makeTest = require('./make-test')
test('test argument-less destroy() throws', function (t) {
t.throws(
diff --git a/test/get-test.js b/test/get-test.js
index 3ad5cf6..1080fd9 100644
--- a/test/get-test.js
+++ b/test/get-test.js
@@ -1,5 +1,5 @@
const test = require('tap').test
- , testCommon = require('./common')
+ , testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
, abstract = require('abstract-leveldown/abstract/get-test')
diff --git a/test/iterator-test.js b/test/iterator-test.js
index 99e8b45..8ff8c4a 100644
--- a/test/iterator-test.js
+++ b/test/iterator-test.js
@@ -1,5 +1,5 @@
const test = require('tap').test
- , testCommon = require('./common')
+ , testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
, abstract = require('abstract-leveldown/abstract/iterator-test')
diff --git a/test/make-test.js b/test/make-test.js
new file mode 100644
index 0000000..d8a8d8f
--- /dev/null
+++ b/test/make-test.js
@@ -0,0 +1,36 @@
+var test = require('tap').test
+var testCommon = require('abstract-leveldown/testCommon')
+var cleanup = testCommon.cleanup
+var location = testCommon.location
+var leveldown = require('../')
+
+module.exports = function (name, testFn) {
+ test(name, function (t) {
+ cleanup(function () {
+ var loc = location()
+ , db = leveldown(loc)
+ , done = function (close) {
+ if (close === false)
+ return cleanup(t.end.bind(t))
+ db.close(function (err) {
+ t.notOk(err, 'no error from close()')
+ cleanup(t.end.bind(t))
+ })
+ }
+ db.open(function (err) {
+ t.notOk(err, 'no error from open()')
+ 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 from batch()')
+ testFn(db, t, done, loc)
+ }
+ )
+ })
+ })
+ })
+}
\ No newline at end of file
diff --git a/test/open-test.js b/test/open-test.js
index 0aa5976..2028a73 100644
--- a/test/open-test.js
+++ b/test/open-test.js
@@ -1,5 +1,5 @@
const test = require('tap').test
- , testCommon = require('./common')
+ , testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
, abstract = require('abstract-leveldown/abstract/open-test')
diff --git a/test/put-get-del-test.js b/test/put-get-del-test.js
index 7323493..6760a73 100644
--- a/test/put-get-del-test.js
+++ b/test/put-get-del-test.js
@@ -1,5 +1,5 @@
const test = require('tap').test
- , testCommon = require('./common')
+ , testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
, fs = require('fs')
, path = require('path')
diff --git a/test/put-test.js b/test/put-test.js
index e21cc5b..07394d4 100644
--- a/test/put-test.js
+++ b/test/put-test.js
@@ -1,5 +1,5 @@
const test = require('tap').test
- , testCommon = require('./common')
+ , testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
, abstract = require('abstract-leveldown/abstract/put-test')
diff --git a/test/repair-test.js b/test/repair-test.js
index d850983..cecb3b7 100644
--- a/test/repair-test.js
+++ b/test/repair-test.js
@@ -3,9 +3,9 @@ const test = require('tap').test
, path = require('path')
, mkfiletree = require('mkfiletree')
, readfiletree = require('readfiletree')
- , testCommon = require('./common')
+ , testCommon = require('abstract-leveldown/testCommon')
, leveldown = require('../')
- , makeTest = testCommon.makeExistingDbTest
+ , makeTest = require('./make-test')
test('test argument-less repair() throws', function (t) {
t.throws(
--
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