couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r959814 - /couchdb/trunk/share/www/script/test/uuids.js
Date Thu, 01 Jul 2010 23:47:04 GMT
Author: jchris
Date: Thu Jul  1 23:47:04 2010
New Revision: 959814

URL: http://svn.apache.org/viewvc?rev=959814&view=rev
Log:
more robust uuids test

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

Modified: couchdb/trunk/share/www/script/test/uuids.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/uuids.js?rev=959814&r1=959813&r2=959814&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/uuids.js (original)
+++ couchdb/trunk/share/www/script/test/uuids.js Thu Jul  1 23:47:04 2010
@@ -93,12 +93,20 @@ couchTests.uuids = function(debug) {
     xhr = CouchDB.request("GET", "/_uuids?count=1000");
     T(xhr.status == 200);
     result = JSON.parse(xhr.responseText);
-    for(var i = 1; i < result.uuids.length; i++) {
-      T(result.uuids[i].length == 32);
-      var u1 = result.uuids[i-1].substr(0, 13);
-      var u2 = result.uuids[i].substr(0, 13);
-      T(u1 < u2, "UTC uuids are only roughly ordered, so this assertion may fail occasionally.
Don't sweat it.");
+    T(result.uuids[1].length == 32);
+
+    // no collisions
+    var seen = {};
+    for(var i in result.uuids) {
+      var id = result.uuids[i];
+      T(seen[id] === undefined);
+      seen[id] = 1;
     }
+
+    // roughly ordered
+    var u1 = result.uuids[1].substr(0, 13);
+    var u2 = result.uuids[result.uuids.length-1].substr(0, 13);
+    T(u1 < u2, "UTC uuids are only roughly ordered, so this assertion may fail occasionally.
Don't sweat it.");
   };
 
   run_on_modified_server([{



Mime
View raw message