Repository: couchdb-fauxton Updated Branches: refs/heads/master 8bca19db1 -> cd4d7ea25
Add deleteDocument custom command to nightwatch Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/cd4d7ea2 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/cd4d7ea2 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/cd4d7ea2 Branch: refs/heads/master Commit: cd4d7ea25e65b4bd3225384c4c889260d83ae8d3 Parents: 8bca19d Author: [email protected] <[email protected]> Authored: Thu Mar 5 17:59:07 2015 -0500 Committer: [email protected] <[email protected]> Committed: Mon Mar 9 15:11:19 2015 -0400 ---------------------------------------------------------------------- .../custom-commands/deleteDocument.js | 40 ++++++++++++++++++++ 1 file changed, 40 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/cd4d7ea2/test/nightwatch_tests/custom-commands/deleteDocument.js ---------------------------------------------------------------------- diff --git a/test/nightwatch_tests/custom-commands/deleteDocument.js b/test/nightwatch_tests/custom-commands/deleteDocument.js new file mode 100644 index 0000000..c398e9b --- /dev/null +++ b/test/nightwatch_tests/custom-commands/deleteDocument.js @@ -0,0 +1,40 @@ +var util = require('util'), + events = require('events'), + helpers = require('../helpers/helpers.js'); + +function DeleteDocument () { + events.EventEmitter.call(this); +} + +util.inherits(DeleteDocument, events.EventEmitter); + +// !!!!! documentName must be all lowercase for this to work + +DeleteDocument.prototype.command = function (databaseName, documentName) { + var that = this, + nano = helpers.getNanoInstance(), + database = nano.use(databaseName), + documentRev; + + database.get(documentName, function(err, body) { + if (!err){ + documentRev = body._rev; + + database.destroy(documentName, documentRev, function (err, body, header) { + if (err) { + console.log('Error in nano DeleteDocument Function: (' + databaseName + ')', err.message); + } + console.log('nano - document: ' + documentName + ' in ' + databaseName + ' is deleted: ', body); + }); + + } else { + console.log("Error in nano- Get documentRev", err.message); + } + // emit the complete event + that.emit('complete'); + }); + + return this; +}; + +module.exports = DeleteDocument;
