Commit b94e9b36 authored by Tristan Cavelier's avatar Tristan Cavelier

fix test bugs on jio

parent ad13d07c
......@@ -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 || "");
};
/**
......
......@@ -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,
......
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment