Skip to content

Commit

Permalink
added delete test
Browse files Browse the repository at this point in the history
  • Loading branch information
fceller committed Apr 9, 2012
1 parent 8c82b5d commit 665d18b
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions js/server/tests/shell-documents.js
Expand Up @@ -254,6 +254,14 @@ function readCollectionDocumentSuiteReadDocument () {
catch (err) {
assertEqual(ERRORS.ERROR_AVOCADO_CONFLICT.code, err.errorNum);
}

var a3 = collection.delete(a1, true);

assertEqual(a3, true);

var a4 = collection.delete(a1, true);

assertEqual(a4, false);
}
};
}
Expand Down Expand Up @@ -422,6 +430,38 @@ function readDocumentSuiteReadDocument () {
assertEqual(a1._id, doc4._id);
assertEqual(a4._rev, doc4._rev);
assertEqual(4, doc4.a);
},

////////////////////////////////////////////////////////////////////////////////
/// @brief delete a document
////////////////////////////////////////////////////////////////////////////////

testDeleteDocument : function () {
var a1 = collection.save({ a : 1});

assertTypeOf("string", a1._id);
assertTypeOf("number", a1._rev);

var a2 = db._replace(a1, { a : 2 });

assertEqual(a1._id, a2._id);
assertNotEqual(a1._rev, a2._rev);

try {
db._delete(a1);
fail();
}
catch (err) {
assertEqual(ERRORS.ERROR_AVOCADO_CONFLICT.code, err.errorNum);
}

var a3 = db._delete(a1, true);

assertEqual(a3, true);

var a4 = db._delete(a1, true);

assertEqual(a4, false);
}
};
}
Expand Down

0 comments on commit 665d18b

Please sign in to comment.