summaryrefslogtreecommitdiff
path: root/share/www/script
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2009-09-14 19:03:36 +0000
committerJohn Christopher Anderson <jchris@apache.org>2009-09-14 19:03:36 +0000
commit7465bf9f8f5eddb469274d99ffc2e7347d2193b3 (patch)
tree806159b3a0686b512d9c09872950925a5601f57f /share/www/script
parentd371de8641a9482f138fbcd4bbb3ead7d85abeba (diff)
removed _all_docs_by_seq in favor of _changes
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@814778 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script')
-rw-r--r--share/www/script/couch.js6
-rw-r--r--share/www/script/test/all_docs.js50
-rw-r--r--share/www/script/test/changes.js13
-rw-r--r--share/www/script/test/conflicts.js4
-rw-r--r--share/www/script/test/etags_views.js6
-rw-r--r--share/www/script/test/replication.js4
6 files changed, 41 insertions, 42 deletions
diff --git a/share/www/script/couch.js b/share/www/script/couch.js
index 81e25f1b..1c529183 100644
--- a/share/www/script/couch.js
+++ b/share/www/script/couch.js
@@ -207,12 +207,12 @@ function CouchDB(name, httpHeaders) {
return this.allDocs({startkey:"_design", endkey:"_design0"});
};
- this.allDocsBySeq = function(options,keys) {
+ this.changes = function(options,keys) {
var req = null;
if(!keys) {
- req = this.request("GET", this.uri + "_all_docs_by_seq" + encodeOptions(options));
+ req = this.request("GET", this.uri + "_changes" + encodeOptions(options));
} else {
- req = this.request("POST", this.uri + "_all_docs_by_seq" + encodeOptions(options), {
+ req = this.request("POST", this.uri + "_changes" + encodeOptions(options), {
headers: {"Content-Type": "application/json"},
body: JSON.stringify({keys:keys})
});
diff --git a/share/www/script/test/all_docs.js b/share/www/script/test/all_docs.js
index c695e24c..34c20921 100644
--- a/share/www/script/test/all_docs.js
+++ b/share/www/script/test/all_docs.js
@@ -42,54 +42,50 @@ couchTests.all_docs = function(debug) {
T(all.offset == 2);
// check that the docs show up in the seq view in the order they were created
- var all_seq = db.allDocsBySeq();
+ var changes = db.changes();
var ids = ["0","3","1","2"];
- for (var i=0; i < all_seq.rows.length; i++) {
- var row = all_seq.rows[i];
- T(row.id == ids[i]);
+ for (var i=0; i < changes.results.length; i++) {
+ var row = changes.results[i];
+ T(row.id == ids[i], "seq order");
};
// it should work in reverse as well
- all_seq = db.allDocsBySeq({descending:true});
+ changes = db.changes({descending:true});
ids = ["2","1","3","0"];
- for (var i=0; i < all_seq.rows.length; i++) {
- var row = all_seq.rows[i];
- T(row.id == ids[i]);
+ for (var i=0; i < changes.results.length; i++) {
+ var row = changes.results[i];
+ T(row.id == ids[i], "descending=true");
};
// check that deletions also show up right
var doc1 = db.open("1");
var deleted = db.deleteDoc(doc1);
T(deleted.ok);
- all_seq = db.allDocsBySeq();
-
+ changes = db.changes();
// the deletion should make doc id 1 have the last seq num
- T(all_seq.rows.length == 4);
- T(all_seq.rows[3].id == "1");
- T(all_seq.rows[3].value.deleted);
-
- // is this a bug?
- // T(all_seq.rows.length == all_seq.total_rows);
+ T(changes.results.length == 4);
+ T(changes.results[3].id == "1");
+ // we've removed deletions from the changes feed as they are on the doc record not the doc_info
+ T(!changes.results[3].deleted);
// do an update
var doc2 = db.open("3");
doc2.updated = "totally";
db.save(doc2);
- all_seq = db.allDocsBySeq();
+ changes = db.changes();
// the update should make doc id 3 have the last seq num
- T(all_seq.rows.length == 4);
- T(all_seq.rows[3].id == "3");
+ T(changes.results.length == 4);
+ T(changes.results[3].id == "3");
// ok now lets see what happens with include docs
- all_seq = db.allDocsBySeq({include_docs: true});
- T(all_seq.rows.length == 4);
- T(all_seq.rows[3].id == "3");
- T(all_seq.rows[3].doc.updated == "totally");
-
- // and on the deleted one, no doc
- T(all_seq.rows[2].value.deleted);
- T(!all_seq.rows[2].doc);
+ changes = db.changes({include_docs: true});
+ T(changes.results.length == 4);
+ T(changes.results[3].id == "3");
+ T(changes.results[3].doc.updated == "totally");
+
+ T(changes.results[2].doc);
+ T(changes.results[2].doc._deleted);
// test the all docs collates sanely
db.save({_id: "Z", foo: "Z"});
diff --git a/share/www/script/test/changes.js b/share/www/script/test/changes.js
index 690727af..a6ce51d5 100644
--- a/share/www/script/test/changes.js
+++ b/share/www/script/test/changes.js
@@ -12,7 +12,7 @@
function jsonp(obj) {
T(jsonp_flag == 0);
- T(obj.results.length == 1 && obj.last_seq==1)
+ T(obj.results.length == 1 && obj.last_seq==1, "jsonp")
jsonp_flag = 1;
}
@@ -25,15 +25,15 @@ couchTests.changes = function(debug) {
var req = CouchDB.request("GET", "/test_suite_db/_changes");
var resp = JSON.parse(req.responseText);
- T(resp.results.length == 0 && resp.last_seq==0)
+ T(resp.results.length == 0 && resp.last_seq==0, "empty db")
var docFoo = {_id:"foo", bar:1};
- db.save(docFoo);
+ T(db.save(docFoo).ok);
req = CouchDB.request("GET", "/test_suite_db/_changes");
var resp = JSON.parse(req.responseText);
- T(resp.results.length == 1 && resp.last_seq==1)
+ T(resp.results.length == 1 && resp.last_seq==1, "one doc db")
T(resp.results[0].changes[0].rev == docFoo._rev)
// test with callback
@@ -232,6 +232,9 @@ couchTests.changes = function(debug) {
function() {
var authOpts = {"headers":{"WWW-Authenticate": "X-Couch-Test-Auth Chris Anderson:mp3"}};
+
+ var req = CouchDB.request("GET", "/_session", authOpts);
+ var resp = JSON.parse(req.responseText);
T(db.save({"user" : "Noah Slater"}).ok);
var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=changes_filter/userCtx", authOpts);
@@ -242,7 +245,7 @@ couchTests.changes = function(debug) {
T(docResp.ok);
req = CouchDB.request("GET", "/test_suite_db/_changes?filter=changes_filter/userCtx", authOpts);
resp = JSON.parse(req.responseText);
- T(resp.results.length == 1);
+ T(resp.results.length == 1, "userCtx");
T(resp.results[0].id == docResp.id);
});
diff --git a/share/www/script/test/conflicts.js b/share/www/script/test/conflicts.js
index fa8162ab..b8b93946 100644
--- a/share/www/script/test/conflicts.js
+++ b/share/www/script/test/conflicts.js
@@ -42,9 +42,9 @@ couchTests.conflicts = function(debug) {
T(e.error == "conflict");
}
- var bySeq = db.allDocsBySeq();
+ var changes = db.changes();
- T( bySeq.rows.length == 1)
+ T( changes.results.length == 1)
// Now clear out the _rev member and save. This indicates this document is
// new, not based on an existing revision.
diff --git a/share/www/script/test/etags_views.js b/share/www/script/test/etags_views.js
index c52be232..8d248983 100644
--- a/share/www/script/test/etags_views.js
+++ b/share/www/script/test/etags_views.js
@@ -72,11 +72,11 @@ couchTests.etags_views = function(debug) {
});
T(xhr.status == 304);
- // by seq
- xhr = CouchDB.request("GET", "/test_suite_db/_all_docs_by_seq");
+ // _changes
+ xhr = CouchDB.request("GET", "/test_suite_db/_changes");
T(xhr.status == 200);
var etag = xhr.getResponseHeader("etag");
- xhr = CouchDB.request("GET", "/test_suite_db/_all_docs_by_seq", {
+ xhr = CouchDB.request("GET", "/test_suite_db/_changes", {
headers: {"if-none-match": etag}
});
T(xhr.status == 304);
diff --git a/share/www/script/test/replication.js b/share/www/script/test/replication.js
index 10b3ce73..c08d128b 100644
--- a/share/www/script/test/replication.js
+++ b/share/www/script/test/replication.js
@@ -100,12 +100,12 @@ couchTests.replication = function(debug) {
};
this.afterAB1 = function(dbA, dbB) {
- var rows = dbB.allDocsBySeq().rows;
+ var rows = dbB.changes({include_docs:true}).results;
var rowCnt = 0;
for (var i=0; i < rows.length; i++) {
if (rows[i].id == "del1") {
rowCnt += 1;
- T(rows[i].value.deleted == true);
+ T(rows[i].doc._deleted == true);
}
};
T(rowCnt == 1);