summaryrefslogtreecommitdiff
path: root/share/www/script/test
diff options
context:
space:
mode:
Diffstat (limited to 'share/www/script/test')
-rw-r--r--share/www/script/test/delayed_commits.js29
-rw-r--r--share/www/script/test/reduce_builtin.js20
-rw-r--r--share/www/script/test/view_update_seq.js7
3 files changed, 55 insertions, 1 deletions
diff --git a/share/www/script/test/delayed_commits.js b/share/www/script/test/delayed_commits.js
index d0c87182..dbb072fb 100644
--- a/share/www/script/test/delayed_commits.js
+++ b/share/www/script/test/delayed_commits.js
@@ -122,4 +122,33 @@ couchTests.delayed_commits = function(debug) {
}
});
+
+ // Test that a conflict can't cause delayed commits to fail
+ run_on_modified_server(
+ [{section: "couchdb",
+ key: "delayed_commits",
+ value: "true"}],
+
+ function() {
+ //First save a document and commit it
+ T(db.save({_id:"6",a:2,b:4}).ok);
+ T(db.ensureFullCommit().ok);
+ //Generate a conflict
+ try {
+ db.save({_id:"6",a:2,b:4});
+ } catch( e) {
+ T(e.error == "conflict");
+ }
+ //Wait for the delayed commit interval to pass
+ var time = new Date();
+ while(new Date() - time < 2000);
+ //Save a new doc
+ T(db.save({_id:"7",a:2,b:4}).ok);
+ //Wait for the delayed commit interval to pass
+ var time = new Date();
+ while(new Date() - time < 2000);
+ //Crash the server and make sure the last doc was written
+ restartServer();
+ T(db.open("7") != null);
+ });
};
diff --git a/share/www/script/test/reduce_builtin.js b/share/www/script/test/reduce_builtin.js
index 0db6bc09..d9635688 100644
--- a/share/www/script/test/reduce_builtin.js
+++ b/share/www/script/test/reduce_builtin.js
@@ -72,6 +72,26 @@ couchTests.reduce_builtin = function(debug) {
T(result.rows[0].value == 2*(summate(numDocs-i) - summate(i-1)));
}
+ // test for trailing characters after builtin functions, desired behaviour
+ // is to disregard any trailing characters
+ // I think the behavior should be a prefix test, so that even "_statsorama"
+ // or "_stats\nare\awesome" should work just as "_stats" does. - JChris
+
+ var trailing = ["\u000a", "orama", "\nare\nawesome", " ", " \n "];
+
+ for(var i=0; i < trailing.length; i++) {
+ result = db.query(map, "_sum" + trailing[i]);
+ T(result.rows[0].value == 2*summate(numDocs));
+ result = db.query(map, "_count" + trailing[i]);
+ T(result.rows[0].value == 1000);
+ result = db.query(map, "_stats" + trailing[i]);
+ T(result.rows[0].value.sum == 2*summate(numDocs));
+ T(result.rows[0].value.count == 1000);
+ T(result.rows[0].value.min == 1);
+ T(result.rows[0].value.max == 500);
+ T(result.rows[0].value.sumsqr == 2*sumsqr(numDocs));
+ }
+
db.deleteDb();
db.createDb();
diff --git a/share/www/script/test/view_update_seq.js b/share/www/script/test/view_update_seq.js
index cfda1a87..e6be3f70 100644
--- a/share/www/script/test/view_update_seq.js
+++ b/share/www/script/test/view_update_seq.js
@@ -18,6 +18,11 @@ couchTests.view_update_seq = function(debug) {
T(db.info().update_seq == 0);
+ resp = db.allDocs({update_seq:true});
+
+ T(resp.rows.length == 0);
+ T(resp.update_seq == 0);
+
var designDoc = {
_id:"_design/test",
language: "javascript",
@@ -35,7 +40,7 @@ couchTests.view_update_seq = function(debug) {
T(db.info().update_seq == 1);
- var resp = db.allDocs({update_seq:true});
+ resp = db.allDocs({update_seq:true});
T(resp.rows.length == 1);
T(resp.update_seq == 1);