From 5ecc6a0e17ef8d54146337a79fe62551ab1969fa Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Thu, 1 Jul 2010 23:47:04 +0000 Subject: more robust uuids test git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@959814 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/uuids.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'share/www/script') 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([{ -- cgit v1.2.3