From 3072bbc46e4d9e0bc2938776c965a5d2e6a15881 Mon Sep 17 00:00:00 2001 From: Benoit Chesneau Date: Wed, 13 Oct 2010 21:02:46 +0000 Subject: 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 --- share/www/script/test/changes.js | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'share') 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"); + } + }); }; -- cgit v1.2.3