From b94e9b369d9c3ae7117f877a7c9e06df41855fbd Mon Sep 17 00:00:00 2001 From: Tristan Cavelier <tristan.cavelier@tiolive.com> Date: Thu, 27 Dec 2012 18:11:52 +0100 Subject: [PATCH] fix test bugs on jio --- src/jio/commands/command.js | 9 ++++++--- src/jio/commands/putAttachmentCommand.js | 10 ++++++++++ src/jio/jio.outro.js | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/jio/commands/command.js b/src/jio/commands/command.js index 8d4b819..2f97f06 100644 --- a/src/jio/commands/command.js +++ b/src/jio/commands/command.js @@ -21,6 +21,9 @@ var command = function(spec, my) { priv.tried = 0; priv.doc = spec.doc || {}; + if (typeof priv.doc !== "object") { + priv.doc = {"_id": priv.doc.toString()}; + } priv.docid = spec.docid || priv.doc._id; priv.option = spec.options || {}; priv.callbacks = spec.callbacks || {}; @@ -98,7 +101,7 @@ var command = function(spec, my) { * @return {string} The data */ that.getAttachmentData = function () { - return priv.doc._data; + return priv.doc._data || ""; }; /** @@ -107,7 +110,7 @@ var command = function(spec, my) { * @return {number} The length */ that.getAttachmentLength = function () { - return priv.doc._data.length; + return (priv.doc._data || "").length; }; /** @@ -125,7 +128,7 @@ var command = function(spec, my) { * @return {string} The md5sum */ that.md5SumAttachmentData = function () { - return hex_md5(priv.doc._data); + return hex_md5(priv.doc._data || ""); }; /** diff --git a/src/jio/commands/putAttachmentCommand.js b/src/jio/commands/putAttachmentCommand.js index 293caae..a5156ef 100644 --- a/src/jio/commands/putAttachmentCommand.js +++ b/src/jio/commands/putAttachmentCommand.js @@ -13,6 +13,16 @@ var putAttachmentCommand = function(spec, my) { }; that.validateState = function () { + if (!(typeof that.getDocId() === "string" && that.getDocId() !== "")) { + that.error({ + "status": 20, + "statusText": "Document Id Required", + "error": "document_id_required", + "message": "The document id is not provided", + "reason": "Document id is undefined" + }); + return false; + } if (typeof that.getAttachmentId() !== "string") { that.error({ "status": 22, diff --git a/src/jio/jio.outro.js b/src/jio/jio.outro.js index 0cdde93..63f033a 100644 --- a/src/jio/jio.outro.js +++ b/src/jio/jio.outro.js @@ -357,7 +357,7 @@ for (k in doc) { doc_with_underscores["_"+k] = doc[k]; } - console.log (doc_with_underscores); + priv.addJob(putAttachmentCommand,{ doc:doc_with_underscores, options:param.options, -- 2.30.9