summaryrefslogtreecommitdiff
path: root/share/www/script/test
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@apache.org>2011-08-10 20:47:27 +0000
committerFilipe David Borba Manana <fdmanana@apache.org>2011-08-10 20:47:27 +0000
commitb2db4f11376472fa801c58f98dcc2e356783e276 (patch)
tree65125d2180df23279a7b16f986a979516f38902f /share/www/script/test
parent5385dee622f39df1110bdca76e2a1b1c3bd5540c (diff)
Merged revision 1156360 from trunk
Prevent data loss on db creation request 1) Create and populate a database 2) Restart the server 3) Send a PUT request to create the database - the server will override the existing file, making all previous documents no longer accessible nor recoverable git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1156361 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/test')
-rw-r--r--share/www/script/test/basics.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/share/www/script/test/basics.js b/share/www/script/test/basics.js
index 30c27c11..5dcf9fa9 100644
--- a/share/www/script/test/basics.js
+++ b/share/www/script/test/basics.js
@@ -246,4 +246,23 @@ couchTests.basics = function(debug) {
result = JSON.parse(xhr.responseText);
TEquals("bad_request", result.error);
TEquals("You tried to DELETE a database with a ?=rev parameter. Did you mean to DELETE a document instead?", result.reason);
+
+ // On restart, a request for creating a database that already exists can
+ // not override the existing database file
+ db = new CouchDB("test_suite_foobar");
+ db.deleteDb();
+ xhr = CouchDB.request("PUT", "/" + db.name);
+ TEquals(201, xhr.status);
+
+ TEquals(true, db.save({"_id": "doc1"}).ok);
+ TEquals(true, db.ensureFullCommit().ok);
+
+ TEquals(1, db.info().doc_count);
+
+ restartServer();
+
+ xhr = CouchDB.request("PUT", "/" + db.name);
+ TEquals(412, xhr.status);
+
+ TEquals(1, db.info().doc_count);
};