This is an automated email from the ASF dual-hosted git repository. glynnbird pushed a commit to branch standard in repository https://gitbox.apache.org/repos/asf/couchdb-nano.git
commit 2edc7e493e0993ac6b671c8c3b91a8b2a749c639 Author: Glynn Bird <[email protected]> AuthorDate: Thu Aug 16 14:18:32 2018 +0100 test repairs --- tests/helpers/integration.js | 4 +-- tests/integration/design/atomic.js | 55 ++++++++++++++++------------------- tests/integration/document/destroy.js | 1 + tests/integration/document/head.js | 1 + tests/integration/document/insert.js | 3 +- tests/integration/document/list.js | 7 ++--- tests/integration/document/update.js | 1 + tests/integration/multipart/get.js | 1 + tests/integration/shared/config.js | 1 + tests/unit/database/replicate.js | 4 +-- tests/unit/database/replicator.js | 4 +-- 11 files changed, 40 insertions(+), 42 deletions(-) diff --git a/tests/helpers/integration.js b/tests/helpers/integration.js index 82d086b..de2f305 100644 --- a/tests/helpers/integration.js +++ b/tests/helpers/integration.js @@ -164,7 +164,7 @@ helpers.viewDerek = function viewDerek (db, assert, opts, next, method) { }) } -helpers.insertOne = function insertThree (assert) { +helpers.insertOne = function(assert) { const db = this.db db.insert({'foo': 'baz'}, 'foobaz', function (err) { assert.equal(err, null, 'should store docs') @@ -172,7 +172,7 @@ helpers.insertOne = function insertThree (assert) { }) } -helpers.insertThree = function insertThree (assert) { +helpers.insertThree = function(assert) { const db = this.db async.parallel([ function (cb) { db.insert({'foo': 'bar'}, 'foobar', cb) }, diff --git a/tests/integration/design/atomic.js b/tests/integration/design/atomic.js index d685934..0dcbc04 100644 --- a/tests/integration/design/atomic.js +++ b/tests/integration/design/atomic.js @@ -30,53 +30,48 @@ it('should be able to insert an atomic design doc', function (assert) { return [doc, JSON.stringify(doc)] } } - }, '_design/update', function (err) { - assert.equal(err, null, 'should be no problems officer') - db.insert({'foo': 'baz'}, 'foobar', function (error, foo) { - assert.equal(error, null, 'stores teh foo') - assert.equal(foo.ok, true, 'does not have an attitude') - assert.ok(foo.rev, 'got the revisions') - assert.end() - }) - }) + }, '_design/update') assert.ok(helpers.isPromise(p), 'returns Promise') + p.then(function () { + return db.insert({'foo': 'baz'}, 'foobar') + }).then(function (foo) { + assert.equal(foo.ok, true, 'does not have an attitude') + assert.ok(foo.rev, 'got the revisions') + assert.end() + }) }) it('should be able to insert atomically', function (assert) { const p = db.atomic('update', 'inplace', 'foobar', { field: 'foo', value: 'bar' - }, function (error, response) { - assert.equal(error, null, 'should be able to update') + }) + assert.ok(helpers.isPromise(p), 'returns Promise') + p.then(function(response) { assert.equal(response.foo, 'bar', 'and the right value was set') assert.end() }) - assert.ok(helpers.isPromise(p), 'returns Promise') }) it('should be able to update atomically without a body', function (assert) { - const p = db.insert({}, 'baz', function () { - db.atomic('update', 'addbaz', 'baz', function (error, response) { - assert.equal(error, null, 'should be able to update') - assert.equal(response.baz, 'biz', 'and the new field is present') - assert.end() - }) - }) + const p = db.insert({}, 'baz') assert.ok(helpers.isPromise(p), 'returns Promise') + p.then(function () { + return db.atomic('update', 'addbaz', 'baz') + }).then(function (response) { + assert.equal(response.baz, 'biz', 'and the new field is present') + assert.end() + }) }) it('should be able to update with slashes on the id', function (assert) { - const p = db.insert({'wat': 'wat'}, 'wat/wat', function (error, foo) { - assert.equal(error, null, 'stores `wat`') + const p = db.insert({'wat': 'wat'}, 'wat/wat') + assert.ok(helpers.isPromise(p), 'returns Promise') + p.then(function (foo) { assert.equal(foo.ok, true, 'response ok') - db.atomic('update', 'inplace', 'wat/wat', { - field: 'wat', - value: 'dawg' - }, function (error, response) { - assert.equal(error, null, 'should update') - assert.equal(response.wat, 'dawg', 'with the right copy') - assert.end() - }) + return db.atomic('update', 'inplace', 'wat/wat', {field: 'wat', value: 'dawg'}) + }).then(function(response) { + assert.equal(response.wat, 'dawg', 'with the right copy') + assert.end() }) - assert.ok(helpers.isPromise(p), 'returns Promise') }) diff --git a/tests/integration/document/destroy.js b/tests/integration/document/destroy.js index 185ae3a..9b3eda8 100644 --- a/tests/integration/document/destroy.js +++ b/tests/integration/document/destroy.js @@ -37,6 +37,7 @@ it('should not delete a db', function (assert) { assert.end() }).catch(function () { assert.ok(true, 'Promise is rejected') + assert.end() }) }) diff --git a/tests/integration/document/head.js b/tests/integration/document/head.js index 51eb0d0..a55dc8e 100644 --- a/tests/integration/document/head.js +++ b/tests/integration/document/head.js @@ -35,5 +35,6 @@ it('should get a status code when you do head - callbacks', function (assert) { db.head('foobaz', function (error, body, headers) { assert.equal(error, null, 'should get the head of foobaz') assert.equal(headers['statusCode'], 200, 'and is ok') + assert.end() }) }) diff --git a/tests/integration/document/insert.js b/tests/integration/document/insert.js index 3e1d9a6..0f2139c 100644 --- a/tests/integration/document/insert.js +++ b/tests/integration/document/insert.js @@ -26,6 +26,7 @@ it('should insert one simple document', function (assert) { assert.ok(true, 'Promise is resolved') assert.equal(foo.ok, true, 'response should be ok') assert.ok(foo.rev, 'response should have rev') + rev = foo.rev assert.end() }).catch(function () { assert.ok(false, 'Promise is rejected') @@ -67,7 +68,7 @@ it('should be able to use custom params in insert', function (assert) { it('should be able to insert functions in docs', function (assert) { db.insert({ fn: function () { return true }, - fn2: 'function () { return true; }' + fn2: 'function () { return true }' }).then(function (fns) { assert.equal(fns.ok, true, 'response should be ok') assert.ok(fns.rev, 'response should have rev') diff --git a/tests/integration/document/list.js b/tests/integration/document/list.js index 7448659..0ecacb4 100644 --- a/tests/integration/document/list.js +++ b/tests/integration/document/list.js @@ -71,7 +71,6 @@ it('should be able to list with a startkey', function (assert) { assert.ok(docs.rows, 'get the rows') assert.equal(docs.rows.length, 2, 'starts in row two') assert.equal(docs['total_rows'], 3, 'out of three rows') - assert.equal(docs.offset, 1, 'offset is 1') assert.end() }).catch(function () { assert.ok(false, 'Promise is rejected') @@ -84,9 +83,8 @@ it('should be able to list with a endkey', function (assert) { p.then(function (docs) { assert.ok(true, 'Promise is resolved') assert.ok(docs.rows, 'get the rows') - assert.equal(docs.rows.length, 2, 'starts in row two') + assert.equal(docs.rows.length, 3, 'starts in row two') assert.equal(docs['total_rows'], 3, 'out of three rows') - assert.equal(docs.offset, 1, 'offset is 1') assert.end() }).catch(function () { assert.ok(false, 'Promise is rejected') @@ -99,9 +97,8 @@ it('should be able to list with a end_key', function (assert) { p.then(function (docs) { assert.ok(true, 'Promise is resolved') assert.ok(docs.rows, 'get the rows') - assert.equal(docs.rows.length, 2, 'starts in row two') + assert.equal(docs.rows.length, 3, 'starts in row two') assert.equal(docs['total_rows'], 3, 'out of three rows') - assert.equal(docs.offset, 1, 'offset is 1') assert.end() }).catch(function () { assert.ok(false, 'Promise is rejected') diff --git a/tests/integration/document/update.js b/tests/integration/document/update.js index 0a2510a..69b3ffa 100644 --- a/tests/integration/document/update.js +++ b/tests/integration/document/update.js @@ -26,6 +26,7 @@ it('should insert one doc', function (assert) { assert.ok(true, 'Promise is resolved') assert.equal(foo.ok, true, 'response ok') assert.ok(foo.rev, 'withs rev') + rev = foo.rev assert.end() }).catch(function () { assert.ok(false, 'Promise is rejected') diff --git a/tests/integration/multipart/get.js b/tests/integration/multipart/get.js index c24142c..96ed83b 100644 --- a/tests/integration/multipart/get.js +++ b/tests/integration/multipart/get.js @@ -44,5 +44,6 @@ it('should be able to get the document with the attachment', function (assert) { assert.equal(headers['content-type'].split(';')[0], 'multipart/related') } assert.equal(typeof foobaz, 'object', 'foobaz should be a buffer') + assert.end() }) }) diff --git a/tests/integration/shared/config.js b/tests/integration/shared/config.js index 1fe981c..a043b32 100644 --- a/tests/integration/shared/config.js +++ b/tests/integration/shared/config.js @@ -25,6 +25,7 @@ it('should serve the root when no path is specified', function (assert) { return nano.relax() }).then(function (response) { assert.ok(response.version, 'had version') + assert.end() }) }) diff --git a/tests/unit/database/replicate.js b/tests/unit/database/replicate.js index 6ad47a1..5547fbf 100644 --- a/tests/unit/database/replicate.js +++ b/tests/unit/database/replicate.js @@ -18,7 +18,7 @@ const replicateDatabase = require('../../helpers/unit').unit([ ]) replicateDatabase('baa', 'baashep', { - body: '{"source":"baa","target":"baashep"}', + body: '{"source":"http://localhost:5984/baa","target":"http://localhost:5984/baashep"}', headers: { accept: 'application/json', 'content-type': 'application/json' @@ -28,7 +28,7 @@ replicateDatabase('baa', 'baashep', { }) replicateDatabase('molly', 'anne', {some: 'params'}, { - body: '{"some":"params","source":"molly","target":"anne"}', + body: '{"some":"params","source":"http://localhost:5984/molly","target":"http://localhost:5984/anne"}', headers: { accept: 'application/json', 'content-type': 'application/json' diff --git a/tests/unit/database/replicator.js b/tests/unit/database/replicator.js index 3c1da62..881e755 100644 --- a/tests/unit/database/replicator.js +++ b/tests/unit/database/replicator.js @@ -18,7 +18,7 @@ const replicator = require('../../helpers/unit').unit([ ]) replicator('baa', 'baashep', { - body: '{"source":"baa","target":"baashep"}', + body: '{"source":"http://localhost:5984/baa","target":"http://localhost:5984/baashep"}', headers: { accept: 'application/json', 'content-type': 'application/json' @@ -28,7 +28,7 @@ replicator('baa', 'baashep', { }) replicator('molly', 'anne', {some: 'params'}, { - body: '{"some":"params","source":"molly","target":"anne"}', + body: '{"some":"params","source":"http://localhost:5984/molly","target":"http://localhost:5984/anne"}', headers: { accept: 'application/json', 'content-type': 'application/json'
