From 7c09f91af89e956bb56b861a17d29841ac39cd2d Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Thu, 12 Jul 2018 01:07:19 +0200 Subject: [PATCH] Merge factory function into testCommon parameter --- test.js | 52 +++++++++++++++---------------- test/batch-test.js | 20 ++++++------ test/chained-batch-test.js | 16 +++++----- test/close-test.js | 4 +-- test/del-test.js | 18 +++++------ test/get-test.js | 18 +++++------ test/iterator-no-snapshot-test.js | 12 +++---- test/iterator-range-test.js | 12 +++---- test/iterator-snapshot-test.js | 12 +++---- test/iterator-test.js | 20 ++++++------ test/leveldown-test.js | 4 +-- test/open-test.js | 29 ++++++++--------- test/put-get-del-test.js | 24 +++++++------- test/put-test.js | 22 ++++++------- 14 files changed, 132 insertions(+), 131 deletions(-) diff --git a/test.js b/test.js index 92d1daa5..671acde9 100644 --- a/test.js +++ b/test.js @@ -8,7 +8,7 @@ var AbstractLevelDOWN = require('./').AbstractLevelDOWN var AbstractIterator = require('./').AbstractIterator var AbstractChainedBatch = require('./').AbstractChainedBatch -function factory () { +var factory = testCommon.factory = function () { return new AbstractLevelDOWN() } @@ -16,45 +16,45 @@ function factory () { * Compatibility with basic LevelDOWN API */ -require('./test/leveldown-test').args(factory, test) +require('./test/leveldown-test').args(test, testCommon) -require('./test/open-test').args(factory, test, testCommon) +require('./test/open-test').args(test, testCommon) -require('./test/del-test').setUp(factory, test, testCommon) -require('./test/del-test').args(factory, test) +require('./test/del-test').setUp(test, testCommon) +require('./test/del-test').args(test, testCommon) -require('./test/get-test').setUp(factory, test, testCommon) -require('./test/get-test').args(factory, test) +require('./test/get-test').setUp(test, testCommon) +require('./test/get-test').args(test, testCommon) -require('./test/put-test').setUp(factory, test, testCommon) -require('./test/put-test').args(factory, test) +require('./test/put-test').setUp(test, testCommon) +require('./test/put-test').args(test, testCommon) -require('./test/put-get-del-test').setUp(factory, test, testCommon) -require('./test/put-get-del-test').errorKeys(test) +require('./test/put-get-del-test').setUp(test, testCommon) +require('./test/put-get-del-test').errorKeys(test, testCommon) // require('./test/put-get-del-test').nonErrorKeys(test, testCommon) -require('./test/put-get-del-test').errorValues() +require('./test/put-get-del-test').errorValues(test, testCommon) require('./test/put-get-del-test').tearDown(test, testCommon) -require('./test/batch-test').setUp(factory, test, testCommon) -require('./test/batch-test').args(test) +require('./test/batch-test').setUp(test, testCommon) +require('./test/batch-test').args(test, testCommon) -require('./test/chained-batch-test').setUp(factory, test, testCommon) -require('./test/chained-batch-test').args(test) +require('./test/chained-batch-test').setUp(test, testCommon) +require('./test/chained-batch-test').args(test, testCommon) -require('./test/close-test').close(factory, test, testCommon) +require('./test/close-test').close(test, testCommon) -require('./test/iterator-test').setUp(factory, test, testCommon) -require('./test/iterator-test').args(test) -require('./test/iterator-test').sequence(test) +require('./test/iterator-test').setUp(test, testCommon) +require('./test/iterator-test').args(test, testCommon) +require('./test/iterator-test').sequence(test, testCommon) require('./test/iterator-test').tearDown(test, testCommon) -require('./test/iterator-range-test').setUp(factory, test, testCommon, []) +require('./test/iterator-range-test').setUp(test, testCommon, []) require('./test/iterator-range-test').tearDown(test, testCommon) -require('./test/iterator-snapshot-test').setUp(factory, test, testCommon) +require('./test/iterator-snapshot-test').setUp(test, testCommon) require('./test/iterator-snapshot-test').tearDown(test, testCommon) -require('./test/iterator-no-snapshot-test').setUp(factory, test, testCommon) +require('./test/iterator-no-snapshot-test').setUp(test, testCommon) require('./test/iterator-no-snapshot-test').tearDown(test, testCommon) function implement (ctor, methods) { @@ -356,7 +356,7 @@ test('test put() extensibility', function (t) { var expectedKey = 'key' var expectedValue = 'value' var Test = implement(AbstractChainedBatch, { _put: spy }) - var test = new Test(factory('foobar')) + var test = new Test(factory()) var returnValue = test.put(expectedKey, expectedValue) t.equal(spy.callCount, 1, 'got _put call') @@ -372,7 +372,7 @@ test('test del() extensibility', function (t) { var spy = sinon.spy() var expectedKey = 'key' var Test = implement(AbstractChainedBatch, { _del: spy }) - var test = new Test(factory('foobar')) + var test = new Test(factory()) var returnValue = test.del(expectedKey) t.equal(spy.callCount, 1, 'got _del call') @@ -386,7 +386,7 @@ test('test del() extensibility', function (t) { test('test clear() extensibility', function (t) { var spy = sinon.spy() var Test = implement(AbstractChainedBatch, { _clear: spy }) - var test = new Test(factory('foobar')) + var test = new Test(factory()) var returnValue = test.clear() t.equal(spy.callCount, 1, 'got _clear call') diff --git a/test/batch-test.js b/test/batch-test.js index a022a4f2..5d924af7 100644 --- a/test/batch-test.js +++ b/test/batch-test.js @@ -2,15 +2,15 @@ var db var verifyNotFoundError = require('./util').verifyNotFoundError var isTypedArray = require('./util').isTypedArray -module.exports.setUp = function (factory, test, testCommon) { +module.exports.setUp = function (test, testCommon) { test('setUp common', testCommon.setUp) test('setUp db', function (t) { - db = factory() + db = testCommon.factory() db.open(t.end.bind(t)) }) } -module.exports.args = function (test) { +module.exports.args = function (test, testCommon) { 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() @@ -159,7 +159,7 @@ module.exports.args = function (test) { }) } -module.exports.batch = function (test) { +module.exports.batch = function (test, testCommon) { test('test batch() with empty array', function (t) { db.batch([], function (err) { t.error(err) @@ -235,7 +235,7 @@ module.exports.batch = function (test) { }) }) } -module.exports.atomic = function (test) { +module.exports.atomic = function (test, testCommon) { test('test multiple batch()', function (t) { t.plan(4) @@ -266,11 +266,11 @@ module.exports.tearDown = function (test, testCommon) { }) } -module.exports.all = function (factory, test, testCommon) { +module.exports.all = function (test, testCommon) { testCommon = testCommon || require('./common') - module.exports.setUp(factory, test, testCommon) - module.exports.args(test) - module.exports.batch(test) - module.exports.atomic(test) + module.exports.setUp(test, testCommon) + module.exports.args(test, testCommon) + module.exports.batch(test, testCommon) + module.exports.atomic(test, testCommon) module.exports.tearDown(test, testCommon) } diff --git a/test/chained-batch-test.js b/test/chained-batch-test.js index 37d2f705..1573b18e 100644 --- a/test/chained-batch-test.js +++ b/test/chained-batch-test.js @@ -24,15 +24,15 @@ function collectBatchOps (batch) { return _operations } -module.exports.setUp = function (factory, test, testCommon) { +module.exports.setUp = function (test, testCommon) { test('setUp common', testCommon.setUp) test('setUp db', function (t) { - db = factory() + db = testCommon.factory() db.open(t.end.bind(t)) }) } -module.exports.args = function (test) { +module.exports.args = function (test, testCommon) { test('test batch#put() with missing `value`', function (t) { db.batch().put('foo1') t.end() @@ -213,7 +213,7 @@ module.exports.args = function (test) { }) } -module.exports.batch = function (test) { +module.exports.batch = function (test, testCommon) { test('test basic batch', function (t) { db.batch([ { type: 'put', key: 'one', value: '1' }, @@ -256,10 +256,10 @@ module.exports.tearDown = function (test, testCommon) { }) } -module.exports.all = function (factory, test, testCommon) { +module.exports.all = function (test, testCommon) { testCommon = testCommon || require('./common') - module.exports.setUp(factory, test, testCommon) - module.exports.args(test) - module.exports.batch(test) + module.exports.setUp(test, testCommon) + module.exports.args(test, testCommon) + module.exports.batch(test, testCommon) module.exports.tearDown(test, testCommon) } diff --git a/test/close-test.js b/test/close-test.js index 394c95bd..64b43c6e 100644 --- a/test/close-test.js +++ b/test/close-test.js @@ -1,7 +1,7 @@ -module.exports.close = function (factory, test, testCommon) { +module.exports.close = function (test, testCommon) { testCommon = testCommon || require('./common') test('test close()', function (t) { - var db = factory() + var db = testCommon.factory() db.open(function (err) { t.error(err) diff --git a/test/del-test.js b/test/del-test.js index 376d769e..07df0b62 100644 --- a/test/del-test.js +++ b/test/del-test.js @@ -1,15 +1,15 @@ var db var verifyNotFoundError = require('./util').verifyNotFoundError -module.exports.setUp = function (factory, test, testCommon) { +module.exports.setUp = function (test, testCommon) { test('setUp common', testCommon.setUp) test('setUp db', function (t) { - db = factory() + db = testCommon.factory() db.open(t.end.bind(t)) }) } -module.exports.args = function (factory, test) { +module.exports.args = function (test, testCommon) { test('test argument-less del() throws', function (t) { t.throws( db.del.bind(db) @@ -39,7 +39,7 @@ module.exports.args = function (factory, test) { test('test custom _serialize*', function (t) { t.plan(3) - var db = factory() + var db = testCommon.factory() db._serializeKey = function (data) { return data } db._del = function (key, options, callback) { t.deepEqual(key, { foo: 'bar' }) @@ -54,7 +54,7 @@ module.exports.args = function (factory, test) { }) } -module.exports.del = function (test) { +module.exports.del = function (test, testCommon) { test('test simple del()', function (t) { db.put('foo', 'bar', function (err) { t.error(err) @@ -84,10 +84,10 @@ module.exports.tearDown = function (test, testCommon) { }) } -module.exports.all = function (factory, test, testCommon) { +module.exports.all = function (test, testCommon) { testCommon = testCommon || require('./common') - module.exports.setUp(factory, test, testCommon) - module.exports.args(factory, test) - module.exports.del(test) + module.exports.setUp(test, testCommon) + module.exports.args(test, testCommon) + module.exports.del(test, testCommon) module.exports.tearDown(test, testCommon) } diff --git a/test/get-test.js b/test/get-test.js index 298bcbb6..3566ea85 100644 --- a/test/get-test.js +++ b/test/get-test.js @@ -2,15 +2,15 @@ var db var verifyNotFoundError = require('./util').verifyNotFoundError var isTypedArray = require('./util').isTypedArray -module.exports.setUp = function (factory, test, testCommon) { +module.exports.setUp = function (test, testCommon) { test('setUp common', testCommon.setUp) test('setUp db', function (t) { - db = factory() + db = testCommon.factory() db.open(t.end.bind(t)) }) } -module.exports.args = function (factory, test) { +module.exports.args = function (test, testCommon) { test('test argument-less get() throws', function (t) { t.throws( db.get.bind(db) @@ -40,7 +40,7 @@ module.exports.args = function (factory, test) { test('test custom _serialize*', function (t) { t.plan(3) - var db = factory() + var db = testCommon.factory() db._serializeKey = function (data) { return data } db._get = function (key, options, callback) { t.deepEqual(key, { foo: 'bar' }) @@ -55,7 +55,7 @@ module.exports.args = function (factory, test) { }) } -module.exports.get = function (test) { +module.exports.get = function (test, testCommon) { test('test simple get()', function (t) { db.put('foo', 'bar', function (err) { t.error(err) @@ -161,10 +161,10 @@ module.exports.tearDown = function (test, testCommon) { }) } -module.exports.all = function (factory, test, testCommon) { +module.exports.all = function (test, testCommon) { testCommon = testCommon || require('./common') - module.exports.setUp(factory, test, testCommon) - module.exports.args(factory, test) - module.exports.get(test) + module.exports.setUp(test, testCommon) + module.exports.args(test, testCommon) + module.exports.get(test, testCommon) module.exports.tearDown(test, testCommon) } diff --git a/test/iterator-no-snapshot-test.js b/test/iterator-no-snapshot-test.js index 872c41f8..c762dfea 100644 --- a/test/iterator-no-snapshot-test.js +++ b/test/iterator-no-snapshot-test.js @@ -1,13 +1,13 @@ var collectEntries = require('level-concat-iterator') -exports.setUp = function (factory, test, testCommon) { +exports.setUp = function (test, testCommon) { test('setUp common', testCommon.setUp) } -exports.noSnapshot = function (factory, test) { +exports.noSnapshot = function (test, testCommon) { function make (run) { return function (t) { - var db = factory() + var db = testCommon.factory() var operations = [ { type: 'put', key: 'a', value: 'a' }, { type: 'put', key: 'b', value: 'b' }, @@ -65,9 +65,9 @@ exports.tearDown = function (test, testCommon) { test('tearDown', testCommon.tearDown) } -exports.all = function (factory, test, testCommon) { +exports.all = function (test, testCommon) { testCommon = testCommon || require('./common') - exports.setUp(factory, test, testCommon) - exports.noSnapshot(factory, test) + exports.setUp(test, testCommon) + exports.noSnapshot(test, testCommon) exports.tearDown(test, testCommon) } diff --git a/test/iterator-range-test.js b/test/iterator-range-test.js index 7d8b217b..7d01b101 100644 --- a/test/iterator-range-test.js +++ b/test/iterator-range-test.js @@ -2,10 +2,10 @@ var collectEntries = require('level-concat-iterator') var db -module.exports.setUp = function (factory, test, testCommon, data) { +module.exports.setUp = function (test, testCommon, data) { test('setUp common', testCommon.setUp) test('setUp db', function (t) { - db = factory() + db = testCommon.factory() db.open(function () { db.batch(data.map(function (d) { return { @@ -18,7 +18,7 @@ module.exports.setUp = function (factory, test, testCommon, data) { }) } -module.exports.range = function (leveldown, test, data) { +module.exports.range = function (test, testCommon, data) { function rangeTest (name, opts, expected) { opts.keyAsBuffer = false opts.valueAsBuffer = false @@ -354,7 +354,7 @@ module.exports.tearDown = function (test, testCommon) { }) } -module.exports.all = function (factory, test, testCommon) { +module.exports.all = function (test, testCommon) { testCommon = testCommon || require('./common') var data = (function () { @@ -371,7 +371,7 @@ module.exports.all = function (factory, test, testCommon) { return d }()) - module.exports.setUp(factory, test, testCommon, data) - module.exports.range(factory, test, data) + module.exports.setUp(test, testCommon, data) + module.exports.range(test, testCommon, data) module.exports.tearDown(test, testCommon) } diff --git a/test/iterator-snapshot-test.js b/test/iterator-snapshot-test.js index c357c606..9a0a5c75 100644 --- a/test/iterator-snapshot-test.js +++ b/test/iterator-snapshot-test.js @@ -1,11 +1,11 @@ -exports.setUp = function (factory, test, testCommon) { +exports.setUp = function (test, testCommon) { test('setUp common', testCommon.setUp) } -exports.snapshot = function (factory, test) { +exports.snapshot = function (test, testCommon) { function make (run) { return function (t) { - var db = factory() + var db = testCommon.factory() db.open(function (err) { t.ifError(err, 'no open error') @@ -82,9 +82,9 @@ exports.tearDown = function (test, testCommon) { test('tearDown', testCommon.tearDown) } -exports.all = function (factory, test, testCommon) { +exports.all = function (test, testCommon) { testCommon = testCommon || require('./common') - exports.setUp(factory, test, testCommon) - exports.snapshot(factory, test) + exports.setUp(test, testCommon) + exports.snapshot(test, testCommon) exports.tearDown(test, testCommon) } diff --git a/test/iterator-test.js b/test/iterator-test.js index f76281a7..fff4214b 100644 --- a/test/iterator-test.js +++ b/test/iterator-test.js @@ -1,14 +1,14 @@ var db -module.exports.setUp = function (factory, test, testCommon) { +module.exports.setUp = function (test, testCommon) { test('setUp common', testCommon.setUp) test('setUp db', function (t) { - db = factory() + db = testCommon.factory() db.open(t.end.bind(t)) }) } -module.exports.args = function (test) { +module.exports.args = function (test, testCommon) { test('test argument-less iterator#next() throws', function (t) { var iterator = db.iterator() t.throws( @@ -49,7 +49,7 @@ module.exports.args = function (test) { }) } -module.exports.sequence = function (test) { +module.exports.sequence = function (test, testCommon) { test('test twice iterator#end() callback with error', function (t) { var iterator = db.iterator() iterator.end(function (err) { @@ -111,7 +111,7 @@ module.exports.sequence = function (test) { }) } -module.exports.iterator = function (test) { +module.exports.iterator = function (test, testCommon) { test('test simple iterator()', function (t) { var data = [ { type: 'put', key: 'foobatch1', value: 'bar1' }, @@ -161,11 +161,11 @@ module.exports.tearDown = function (test, testCommon) { }) } -module.exports.all = function (factory, test, testCommon) { +module.exports.all = function (test, testCommon) { testCommon = testCommon || require('./common') - module.exports.setUp(factory, test, testCommon) - module.exports.args(test) - module.exports.sequence(test) - module.exports.iterator(test) + module.exports.setUp(test, testCommon) + module.exports.args(test, testCommon) + module.exports.sequence(test, testCommon) + module.exports.iterator(test, testCommon) module.exports.tearDown(test, testCommon) } diff --git a/test/leveldown-test.js b/test/leveldown-test.js index de5419b3..58822c70 100644 --- a/test/leveldown-test.js +++ b/test/leveldown-test.js @@ -1,6 +1,6 @@ -module.exports.args = function (factory, test) { +module.exports.args = function (test, testCommon) { test('test database open method exists', function (t) { - var db = factory() + var db = testCommon.factory() t.ok(db, 'database object returned') t.ok(typeof db.open === 'function', 'open() function exists') t.end() diff --git a/test/open-test.js b/test/open-test.js index 9d597e12..a85959e2 100644 --- a/test/open-test.js +++ b/test/open-test.js @@ -2,9 +2,9 @@ module.exports.setUp = function (test, testCommon) { test('setUp', testCommon.setUp) } -module.exports.args = function (factory, test) { +module.exports.args = function (test, testCommon) { test('test database open no-arg throws', function (t) { - var db = factory() + var db = testCommon.factory() t.throws( db.open.bind(db) , { name: 'Error', message: 'open() requires a callback argument' } @@ -14,7 +14,7 @@ module.exports.args = function (factory, test) { }) test('test callback-less, 1-arg, open() throws', function (t) { - var db = factory() + var db = testCommon.factory() t.throws( db.open.bind(db, {}) , { name: 'Error', message: 'open() requires a callback argument' } @@ -24,9 +24,9 @@ module.exports.args = function (factory, test) { }) } -module.exports.open = function (factory, test) { +module.exports.open = function (test, testCommon) { test('test database open, no options', function (t) { - var db = factory() + var db = testCommon.factory() // default createIfMissing=true, errorIfExists=false db.open(function (err) { @@ -38,7 +38,7 @@ module.exports.open = function (factory, test) { }) test('test database open, options and callback', function (t) { - var db = factory() + var db = testCommon.factory() // default createIfMissing=true, errorIfExists=false db.open({}, function (err) { @@ -48,8 +48,9 @@ module.exports.open = function (factory, test) { }) }) }) + test('test database open, close and open', function (t) { - var db = factory() + var db = testCommon.factory() db.open(function (err) { t.error(err) @@ -66,9 +67,9 @@ module.exports.open = function (factory, test) { }) } -module.exports.openAdvanced = function (factory, test) { +module.exports.openAdvanced = function (test, testCommon) { test('test database open createIfMissing:false', function (t) { - var db = factory() + var db = testCommon.factory() var async = false db.open({ createIfMissing: false }, function (err) { @@ -82,7 +83,7 @@ module.exports.openAdvanced = function (factory, test) { }) test('test database open errorIfExists:true', function (t) { - var db = factory() + var db = testCommon.factory() db.open({}, function (err) { t.error(err) @@ -108,11 +109,11 @@ module.exports.tearDown = function (test, testCommon) { test('tearDown', testCommon.tearDown) } -module.exports.all = function (factory, test, testCommon) { +module.exports.all = function (test, testCommon) { testCommon = testCommon || require('./common') module.exports.setUp(test, testCommon) - module.exports.args(factory, test) - module.exports.open(factory, test) - module.exports.openAdvanced(factory, test) + module.exports.args(test, testCommon) + module.exports.open(test, testCommon) + module.exports.openAdvanced(test, testCommon) module.exports.tearDown(test, testCommon) } diff --git a/test/put-get-del-test.js b/test/put-get-del-test.js index 62ec44ce..0e3ed2c6 100644 --- a/test/put-get-del-test.js +++ b/test/put-get-del-test.js @@ -91,15 +91,15 @@ function makeErrorKeyTest (test, type, key, expectedError) { makePutErrorTest(test, type, key, 'foo', expectedError) } -module.exports.setUp = function (factory, test, testCommon) { +module.exports.setUp = function (test, testCommon) { test('setUp common', testCommon.setUp) test('setUp db', function (t) { - db = factory() + db = testCommon.factory() db.open(t.end.bind(t)) }) } -module.exports.errorKeys = function (test) { +module.exports.errorKeys = function (test, testCommon) { makeErrorKeyTest(test, 'null key', null, /key cannot be `null` or `undefined`/) makeErrorKeyTest(test, 'undefined key', undefined, /key cannot be `null` or `undefined`/) makeErrorKeyTest(test, 'empty String key', '', /key cannot be an empty String/) @@ -107,7 +107,7 @@ module.exports.errorKeys = function (test) { makeErrorKeyTest(test, 'empty Array key', [], /key cannot be an empty String/) } -module.exports.nonErrorKeys = function (test) { +module.exports.nonErrorKeys = function (test, testCommon) { // valid falsey keys makePutGetDelSuccessfulTest(test, '`false` key', false, 'foo false') makePutGetDelSuccessfulTest(test, '`0` key', 0, 'foo 0') @@ -130,10 +130,10 @@ module.exports.nonErrorKeys = function (test) { makePutGetDelSuccessfulTest(test, 'Array value', 'foo', [1, 2, 3, 4]) } -module.exports.errorValues = function () { +module.exports.errorValues = function (test, testCommon) { } -module.exports.nonErrorValues = function (test) { +module.exports.nonErrorValues = function (test, testCommon) { // valid falsey values makePutGetDelSuccessfulTest(test, '`false` value', 'foo false', false) makePutGetDelSuccessfulTest(test, '`0` value', 'foo 0', 0) @@ -167,12 +167,12 @@ module.exports.tearDown = function (test, testCommon) { }) } -module.exports.all = function (factory, test, testCommon) { +module.exports.all = function (test, testCommon) { testCommon = testCommon || require('./common') - module.exports.setUp(factory, test, testCommon) - module.exports.errorKeys(test) - module.exports.nonErrorKeys(test) - module.exports.errorValues(test) - module.exports.nonErrorValues(test) + module.exports.setUp(test, testCommon) + module.exports.errorKeys(test, testCommon) + module.exports.nonErrorKeys(test, testCommon) + module.exports.errorValues(test, testCommon) + module.exports.nonErrorValues(test, testCommon) module.exports.tearDown(test, testCommon) } diff --git a/test/put-test.js b/test/put-test.js index abfd3fb8..326d368f 100644 --- a/test/put-test.js +++ b/test/put-test.js @@ -1,15 +1,15 @@ var db var isTypedArray = require('./util').isTypedArray -module.exports.setUp = function (factory, test, testCommon) { +module.exports.setUp = function (test, testCommon) { test('setUp common', testCommon.setUp) test('setUp db', function (t) { - db = factory() + db = testCommon.factory() db.open(t.end.bind(t)) }) } -module.exports.args = function (factory, test) { +module.exports.args = function (test, testCommon) { test('test argument-less put() throws', function (t) { t.throws( db.put.bind(db) @@ -48,7 +48,7 @@ module.exports.args = function (factory, test) { test('test _serialize object', function (t) { t.plan(3) - var db = factory() + var db = testCommon.factory() db._put = function (key, value, opts, callback) { t.ok(key) t.ok(value) @@ -61,7 +61,7 @@ module.exports.args = function (factory, test) { test('test custom _serialize*', function (t) { t.plan(4) - var db = factory() + var db = testCommon.factory() db._serializeKey = db._serializeValue = function (data) { return data } db._put = function (key, value, options, callback) { t.deepEqual(key, { foo: 'bar' }) @@ -77,7 +77,7 @@ module.exports.args = function (factory, test) { }) } -module.exports.put = function (test) { +module.exports.put = function (test, testCommon) { test('test simple put()', function (t) { db.put('foo', 'bar', function (err) { t.error(err) @@ -94,7 +94,7 @@ module.exports.put = function (test) { }) } -module.exports.sync = function (test) { +module.exports.sync = function (test, testCommon) { test('sync put', function (t) { db.put('foo', 'bar', { sync: true }, function (err) { t.error(err) @@ -122,10 +122,10 @@ module.exports.tearDown = function (test, testCommon) { }) } -module.exports.all = function (factory, test, testCommon) { +module.exports.all = function (test, testCommon) { testCommon = testCommon || require('./common') - module.exports.setUp(factory, test, testCommon) - module.exports.args(factory, test) - module.exports.put(test) + module.exports.setUp(test, testCommon) + module.exports.args(test, testCommon) + module.exports.put(test, testCommon) module.exports.tearDown(test, testCommon) }