diff options
author | Damien F. Katz <damien@apache.org> | 2009-06-01 00:27:28 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2009-06-01 00:27:28 +0000 |
commit | ce663765f3f774d07c58579dff8b5398fdfbb6ce (patch) | |
tree | 5be1ca81998af7fb87402b5857a016cee84316f0 /share/www/script | |
parent | 958c8a6c8c0aa03d854a1aef4ad06e0ae6583375 (diff) |
Added tests for heartbeat and timeout options in the _changes api.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@780539 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script')
-rw-r--r-- | share/www/script/test/changes.js | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/share/www/script/test/changes.js b/share/www/script/test/changes.js index fe8a1cd5..98f31d6f 100644 --- a/share/www/script/test/changes.js +++ b/share/www/script/test/changes.js @@ -30,6 +30,12 @@ couchTests.changes = function(debug) { T(resp.results.length == 1 && resp.last_seq==1) T(resp.results[0].changes[0].rev == docFoo._rev) + + + req = CouchDB.request("GET", "/test_suite_db/_changes?continuous=true&timeout=10"); + var resp = JSON.parse(req.responseText); + T(resp.results.length == 1 && resp.last_seq==1) + T(resp.results[0].changes[0].rev == docFoo._rev) var xhr; @@ -43,7 +49,7 @@ couchTests.changes = function(debug) { // with real async support. var sleep = function(msecs) { - // by making a slow sync request, weallows the waiting XHR request data + // by making a slow sync request, we allow the waiting XHR request data // to be received. var req = CouchDB.request("GET", "/_sleep?time=" + msecs); T(JSON.parse(req.responseText).ok == true); @@ -55,6 +61,7 @@ couchTests.changes = function(debug) { } return JSON.parse(line); } + xhr.open("GET", "/test_suite_db/_changes?continuous=true", true); xhr.send(""); @@ -89,6 +96,19 @@ couchTests.changes = function(debug) { T(change.seq == 3); T(change.id == "baz"); T(change.changes[0].rev == docBaz._rev); + + + xhr = CouchDB.newXhr(); + //verify the hearbeat newlines are sent + xhr.open("GET", "/test_suite_db/_changes?continuous=true&heartbeat=10", true); + xhr.send(""); + + sleep(100); + + var str = xhr.responseText; + + T(str.charAt(str.length - 1) == "\n") + T(str.charAt(str.length - 2) == "\n") } }; |