You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2016/04/25 18:56:13 UTC

[8/9] couchdb commit: updated refs/heads/master to 01edf89

Test non-conflicting user doc


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/7bb5a810
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/7bb5a810
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/7bb5a810

Branch: refs/heads/master
Commit: 7bb5a8109ad913b9eb4652b0f55fbe83c83e4bf3
Parents: 1ae2c75
Author: sebastianro <se...@apache.org>
Authored: Sun Apr 24 13:27:19 2016 +0200
Committer: sebastianro <se...@apache.org>
Committed: Sun Apr 24 13:27:19 2016 +0200

----------------------------------------------------------------------
 test/javascript/tests/users_db.js | 44 +++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/7bb5a810/test/javascript/tests/users_db.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/users_db.js b/test/javascript/tests/users_db.js
index 2835015..e59b398 100644
--- a/test/javascript/tests/users_db.js
+++ b/test/javascript/tests/users_db.js
@@ -61,38 +61,48 @@ couchTests.users_db = function(debug) {
     });
     T(s.name == null);
     T(s.info.authenticated == "default");
+
+    // make sure we'll not hit the cache with this
+    var kchrisUserDoc = CouchDB.prepareUserDoc({
+      name: "kchris@apache.org"
+    }, "sadbone");
+    T(usersDb.save(kchrisUserDoc).ok);
     
     // save with new_edits=false to force conflict save does no more work => actually replicate and change simultanously
     CouchDB.replicate(usersDb.name, usersDbAlt.name);
-    // ok, now create a conflicting edit on the jchris doc, and make sure there's no login.
-    var jchrisUser2 = JSON.parse(JSON.stringify(jchrisUserDoc));
-    jchrisUser2.foo = "bar";
-    T(usersDb.save(jchrisUser2).ok);
+    // ok, now create a conflicting edit on the kchris doc, and make sure there's no login.
+    var kchrisUser2 = JSON.parse(JSON.stringify(kchrisUserDoc));
+    kchrisUser2.foo = "bar";
+    T(usersDb.save(kchrisUser2).ok);
     // now the other
-    var jchrisUser3 = JSON.parse(JSON.stringify(jchrisUserDoc));
-    jchrisUser3.foo = "barrrr";
-    T(usersDbAlt.save(jchrisUser3).ok);
+    var kchrisUser3 = JSON.parse(JSON.stringify(kchrisUserDoc));
+    kchrisUser3.foo = "barrrr";
+    T(usersDbAlt.save(kchrisUser3).ok);
     // and replicate back
     CouchDB.replicate(usersDbAlt.name, usersDb.name);
 
-    var jchrisWithConflict = usersDb.open(jchrisUserDoc._id, {conflicts : true, revs_info: true});
-    T(jchrisWithConflict._conflicts.length == 1);
+    var kchrisWithConflict = usersDb.open(kchrisUserDoc._id, {conflicts : true, revs_info: true});
+    T(kchrisWithConflict._conflicts.length == 1);
     
     // no login with conflicted user doc
     CouchDB.logout();
-    var s = CouchDB.session({
-      headers : {
-        "Authorization" : "Basic amNocmlzQGFwYWNoZS5vcmc6ZnVubnlib25l"
-      }
-    });
-// TODO: conflicting Docs perfectly qualify 4 login
-//    T(s.userCtx.name == null);
+    var s = null;
+    try {
+      s = CouchDB.session({
+        headers : {
+          "Authorization" : "Basic a2NocmlzQGFwYWNoZS5vcmc6ZnVubnlib25l"
+        }
+      });
+    }catch(e){
+      // old test had name==null, now we might have an error. Anyway: test below
+    }
+    T(s == null || s.userCtx.name == null);
 
     // you can delete a user doc
     s = CouchDB.session().userCtx;
     T(s.name == null);
     T(s.roles.indexOf("_admin") !== -1);
-    T(usersDb.deleteDoc(jchrisWithConflict).ok);
+    T(usersDb.deleteDoc(kchrisWithConflict).ok);
 
     // you can't change doc from type "user"
 // TODO: needs design doc (see above)