couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r754563 - in /couchdb/trunk: share/www/script/test/replication.js src/couchdb/couch_doc.erl
Date Sun, 15 Mar 2009 00:15:41 GMT
Author: jchris
Date: Sun Mar 15 00:15:40 2009
New Revision: 754563

URL: http://svn.apache.org/viewvc?rev=754563&view=rev
Log:
error message on invalid rev format.
another replication test.

Modified:
    couchdb/trunk/share/www/script/test/replication.js
    couchdb/trunk/src/couchdb/couch_doc.erl

Modified: couchdb/trunk/share/www/script/test/replication.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/replication.js?rev=754563&r1=754562&r2=754563&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/replication.js (original)
+++ couchdb/trunk/share/www/script/test/replication.js Sun Mar 15 00:15:40 2009
@@ -72,6 +72,7 @@
       },
     
      deletes_test: new function () {
+        // make sure deletes are replicated
         this.init = function(dbA, dbB) {
           T(dbA.save({_id:"foo1",value:"a"}).ok);
         };
@@ -90,6 +91,27 @@
         };
       },
       
+      deleted_test : new function() {
+        // docs created and deleted on a single node are also replicated
+        this.init = function(dbA, dbB) {
+          T(dbA.save({_id:"del1",value:"a"}).ok);
+          var docA = dbA.open("del1");
+          dbA.deleteDoc(docA);
+        };
+        
+        this.afterAB1 = function(dbA, dbB) {
+          var rows = dbB.allDocsBySeq().rows;
+          var rowCnt = 0;
+          for (var i=0; i < rows.length; i++) {
+            if (rows[i].id == "del1") {
+              rowCnt += 1;
+              T(rows[i].value.deleted == true);
+            }
+          };
+          T(rowCnt == 1);
+        };
+      },
+      
       slashes_in_ids_test: new function () {
         // make sure docs with slashes in id replicate properly
         this.init = function(dbA, dbB) {

Modified: couchdb/trunk/src/couchdb/couch_doc.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_doc.erl?rev=754563&r1=754562&r2=754563&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_doc.erl (original)
+++ couchdb/trunk/src/couchdb/couch_doc.erl Sun Mar 15 00:15:40 2009
@@ -129,9 +129,12 @@
 parse_rev(Rev) when is_binary(Rev) ->
     parse_rev(?b2l(Rev));
 parse_rev(Rev) ->
-    {Pos, [$- | RevId]} = lists:splitwith(fun($-) -> false; (_) -> true end, Rev),
-    {list_to_integer(Pos), ?l2b(RevId)}.
-
+    SplitRev = lists:splitwith(fun($-) -> false; (_) -> true end, Rev),
+    case SplitRev of 
+        {Pos, [$- | RevId]} -> {list_to_integer(Pos), ?l2b(RevId)};
+        _Else -> throw({bad_request, <<"Invalid rev format">>})
+    end.
+    
 parse_revs([]) ->
     [];
 parse_revs([Rev | Rest]) ->



Mime
View raw message