Bug 810053 - Add explicit test for obsolete document deletion; r=rnewman
authorGregory Szorc <gps@mozilla.com>
Thu, 08 Nov 2012 15:24:56 -0800
changeset 113825 6b0dc316e003dbf93b7eaad59fd5548b862e6f65
parent 113824 c73d02e3cc39e30a9517866048ff18189850cf7a
child 113826 5901554be0faae6973827bd41752badb03bc1950
push id23890
push userryanvm@gmail.com
push dateWed, 21 Nov 2012 02:43:32 +0000
treeherdermozilla-central@4f19e7fd8bea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs810053
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 810053 - Add explicit test for obsolete document deletion; r=rnewman
services/common/modules-testing/bagheeraserver.js
services/common/tests/unit/test_bagheera_client.js
--- a/services/common/modules-testing/bagheeraserver.js
+++ b/services/common/modules-testing/bagheeraserver.js
@@ -268,16 +268,17 @@ BagheeraServer.prototype = {
       this._log.info("JSON parse error.");
       throw HTTP_400;
     }
 
     this.namespaces[namespace][id] = doc;
 
     if (request.hasHeader("X-Obsolete-Document")) {
       let obsolete = request.getHeader("X-Obsolete-Document");
+      this._log.info("Deleting from X-Obsolete-Document header: " + obsolete);
       delete this.namespaces[namespace][obsolete];
     }
 
     response.setStatusLine(request.httpVersion, 201, "Created");
     response.setHeader("Content-Type", "text/plain");
 
     let body = id;
     response.bodyOutputStream.write(body, body.length);
--- a/services/common/tests/unit/test_bagheera_client.js
+++ b/services/common/tests/unit/test_bagheera_client.js
@@ -67,16 +67,32 @@ add_test(function test_post_json_bad_dat
     function onResult(result) {
     do_check_true(result.transportSuccess);
     do_check_false(result.serverSuccess);
 
     server.stop(run_next_test);
   });
 });
 
+add_test(function test_post_json_delete_obsolete() {
+  let [client, server] = getClientAndServer();
+  server.createNamespace("foo");
+  server.setDocument("foo", "obsolete", "Old payload");
+
+  let promise = client.uploadJSON("foo", "new", {foo: "bar"}, "obsolete");
+  promise.then(function onSuccess(result) {
+    do_check_true(result.transportSuccess);
+    do_check_true(result.serverSuccess);
+    do_check_true(server.hasDocument("foo", "new"));
+    do_check_false(server.hasDocument("foo", "obsolete"));
+
+    server.stop(run_next_test);
+  });
+});
+
 add_test(function test_delete_document() {
   let [client, server] = getClientAndServer();
 
   server.createNamespace("foo");
   server.setDocument("foo", "bar", "{}");
 
   client.deleteDocument("foo", "bar").then(function onResult(result) {
     do_check_true(result.transportSuccess);