summaryrefslogtreecommitdiff
path: root/share/www/script/test
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2010-07-01 23:47:04 +0000
committerJohn Christopher Anderson <jchris@apache.org>2010-07-01 23:47:04 +0000
commit5ecc6a0e17ef8d54146337a79fe62551ab1969fa (patch)
tree59f925fcbcbe33f3f6a632e3a393ec05155915ce /share/www/script/test
parent6fd817965347b953de30d1e0c9b9e471c7532eee (diff)
more robust uuids test
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@959814 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/test')
-rw-r--r--share/www/script/test/uuids.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/share/www/script/test/uuids.js b/share/www/script/test/uuids.js
index 35ac2683..fc33a105 100644
--- a/share/www/script/test/uuids.js
+++ b/share/www/script/test/uuids.js
@@ -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([{