diff options
author | Damien F. Katz <damien@apache.org> | 2008-08-08 21:06:29 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2008-08-08 21:06:29 +0000 |
commit | f2275fd25463764ea059b32ffb689baeeebc1ca1 (patch) | |
tree | a97ae4f116446f617f2b9339762dbb5b5bee7dee /share/www/script/couch_tests.js | |
parent | a33cf09319d0b174ec9c509c815da160b7091ab3 (diff) |
Idempotent document creation support, new HTTP api to generate UUIDs and support in the couch.js library for using them. Creating uuids client side ensure that document creation happens only once, despite automatic network retries.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@684092 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/couch_tests.js')
-rw-r--r-- | share/www/script/couch_tests.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index 539b9a12..08c1bbe9 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -194,6 +194,42 @@ var tests = { } }, + uuids: function(debug) { + var db = new CouchDB("test_suite_db"); + db.deleteDb(); + db.createDb(); + if (debug) debugger; + + // a single UUID without an explicit count + var xhr = CouchDB.request("POST", "/_uuids"); + T(xhr.status == 200); + var result = JSON.parse(xhr.responseText); + T(result.uuids.length == 1); + var first = result.uuids[0]; + + // a single UUID with an explicit count + xhr = CouchDB.request("POST", "/_uuids?count=1"); + T(xhr.status == 200); + result = JSON.parse(xhr.responseText); + T(result.uuids.length == 1); + var second = result.uuids[0]; + T(first != second); + + // no collisions with 1,000 UUIDs + xhr = CouchDB.request("POST", "/_uuids?count=1000"); + T(xhr.status == 200); + result = JSON.parse(xhr.responseText); + T( result.uuids.length == 1000 ); + var seen = {}; + for(var i in result.uuids) { + var id = result.uuids[i]; + T(seen[id] === undefined); + seen[id] = 1; + } + + // check our library + }, + bulk_docs: function(debug) { var db = new CouchDB("test_suite_db"); db.deleteDb(); |