couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rand...@apache.org
Subject svn commit: r1166980 - /couchdb/trunk/share/www/script/test/conflicts.js
Date Fri, 09 Sep 2011 03:42:23 GMT
Author: randall
Date: Fri Sep  9 03:42:22 2011
New Revision: 1166980

URL: http://svn.apache.org/viewvc?rev=1166980&view=rev
Log:
js test cases to exercise COUCHDB-1268

Modified:
    couchdb/trunk/share/www/script/test/conflicts.js

Modified: couchdb/trunk/share/www/script/test/conflicts.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/conflicts.js?rev=1166980&r1=1166979&r2=1166980&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/conflicts.js (original)
+++ couchdb/trunk/share/www/script/test/conflicts.js Fri Sep  9 03:42:22 2011
@@ -56,6 +56,36 @@ couchTests.conflicts = function(debug) {
     T(e.error == "conflict");
   }
 
+  // Make a few bad requests, specifying conflicting revs
+  // ?rev doesn't match body
+  var xhr = CouchDB.request("PUT", "/test_suite_db/foo?rev=1-foobar", {
+    body : JSON.stringify(doc)
+  });
+  T(xhr.status == 400);
+
+  // If-Match doesn't match body
+  xhr = CouchDB.request("PUT", "/test_suite_db/foo", {
+    headers: {"If-Match": "1-foobar"},
+    body: JSON.stringify(doc)
+  });
+  T(xhr.status == 400);
+
+  // ?rev= doesn't match If-Match
+  xhr = CouchDB.request("PUT", "/test_suite_db/foo?rev=1-boobaz", {
+    headers: {"If-Match": "1-foobar"},
+    body: JSON.stringify(doc2)
+  });
+  T(xhr.status == 400);
+
+  // Now update the document using ?rev=
+  xhr = CouchDB.request("PUT", "/test_suite_db/foo?rev=" + doc._rev, {
+    body: JSON.stringify(doc)
+  });
+  T(xhr.status == 201);
+
+  // reopen
+  var doc = db.open(doc._id);
+
   // Now delete the document from the database
   T(db.deleteDoc(doc).ok);
 



Mime
View raw message