diff options
author | Benoit Chesneau <benoitc@apache.org> | 2010-10-13 21:02:46 +0000 |
---|---|---|
committer | Benoit Chesneau <benoitc@apache.org> | 2010-10-13 21:02:46 +0000 |
commit | 3072bbc46e4d9e0bc2938776c965a5d2e6a15881 (patch) | |
tree | 178cdaa80262b96d47ae562696412369befd08c6 /share/www/script/test/changes.js | |
parent | c15fe1593ab99b439d2dfc187e6d0b0e20b985a8 (diff) |
get _changes on specific docids
/POST /db/_changes
{"doc_ids": ["docid1", ...]}
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1022291 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/test/changes.js')
-rw-r--r-- | share/www/script/test/changes.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/share/www/script/test/changes.js b/share/www/script/test/changes.js index 50649508..b1404ba0 100644 --- a/share/www/script/test/changes.js +++ b/share/www/script/test/changes.js @@ -181,6 +181,8 @@ couchTests.changes = function(debug) { T(change.id == "barz"); T(change.changes[0].rev == docBarz._rev); T(lines[3]=='"last_seq":4}'); + + } // test the filtered changes @@ -396,6 +398,57 @@ couchTests.changes = function(debug) { T(resp.results.length === 2); T(resp.results[0].id === "doc2"); T(resp.results[1].id === "doc4"); + + // test filtering on docids + // + + options = { + headers: {"Content-Type": "application/json"}, + body: JSON.stringify({"doc_ids": ["something", "anotherthing", "andmore"]}) + }; + + var req = CouchDB.request("POST", "/test_suite_db/_changes", options); + var resp = JSON.parse(req.responseText); + T(resp.results.length === 0); + + T(db.save({"_id":"something", "bop" : "plankton"}).ok); + var req = CouchDB.request("POST", "/test_suite_db/_changes", options); + var resp = JSON.parse(req.responseText); + T(resp.results.length === 1); + T(resp.results[0].id === "something"); + + T(db.save({"_id":"anotherthing", "bop" : "plankton"}).ok); + var req = CouchDB.request("POST", "/test_suite_db/_changes", options); + var resp = JSON.parse(req.responseText); + T(resp.results.length === 2); + T(resp.results[0].id === "something"); + T(resp.results[1].id === "anotherthing"); + + + if (!is_safari && xhr) { + // filter docids with continuous + xhr = CouchDB.newXhr(); + xhr.open("POST", "/test_suite_db/_changes?feed=continuous&timeout=500&since=7", true); + xhr.setRequestHeader("Content-Type", "application/json"); + + xhr.send(options.body); + + T(db.save({"_id":"andmore", "bop" : "plankton"}).ok); + + + waitForSuccess(function() { + if (xhr.readyState != 4) { + throw("still waiting"); + } + console.log(xhr.readyState); + }, "andmore-only"); + + line = JSON.parse(xhr.responseText.split("\n")[0]); + console.log(line); + T(line.seq == 8); + T(line.id == "andmore"); + } + }); }; |