Bug 694657 - Part 1: Sync: test JS server 404 for GET on missing WBO. r=philikon
authorRichard Newman <rnewman@mozilla.com>
Sat, 15 Oct 2011 15:29:11 -0700
changeset 78616 8c1ad90b6804312e7866cb733cf12368af4628a4
parent 78615 9c072e3fa13857e553ddc24e9cb5ecb30ab97aec
child 78617 d9281069d6b824361e8a772e5d18edb9b21faf29
push id258
push userrnewman@mozilla.com
push dateSat, 15 Oct 2011 22:32:44 +0000
treeherderservices-central@47950c8ae523 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilikon
bugs694657
milestone10.0a1
Bug 694657 - Part 1: Sync: test JS server 404 for GET on missing WBO. r=philikon
services/sync/tests/unit/head_http_server.js
services/sync/tests/unit/test_httpd_sync_server.js
--- a/services/sync/tests/unit/head_http_server.js
+++ b/services/sync/tests/unit/head_http_server.js
@@ -873,16 +873,20 @@ SyncServer.prototype = {
         this._log.warn("SyncServer: Unknown storage operation " + rest);
         throw HTTP_404;
       }
       let [all, collection, wboID] = match;
       let coll = this.getCollection(username, collection);
       switch (req.method) {
         case "GET":
           if (!coll) {
+            if (wboID) {
+              respond(404, "Not found", "Not found");
+              return;
+            }
             // *cries inside*: Bug 687299.
             respond(200, "OK", "[]");
             return;
           }
           if (!wboID) {
             return coll.collectionHandler(req, resp);
           }
           let wbo = coll.wbo(wboID);
--- a/services/sync/tests/unit/test_httpd_sync_server.js
+++ b/services/sync/tests/unit/test_httpd_sync_server.js
@@ -198,24 +198,35 @@ add_test(function test_storage_request()
     _("Testing that GET on /storage fails.");
     let req = localRequest(storageURL);
     req.get(function (err) {
       do_check_eq(this.response.status, 405);
       do_check_eq(this.response.headers["allow"], "DELETE");
       Utils.nextTick(next);
     });
   }
-  server.start(8080, function () {
-    retrieveWBONotExists(
-      retrieveWBOExists.bind(this,
-        getStorageFails.bind(this,
-          deleteStorage.bind(this, function () {
-            server.stop(run_next_test);
-          }))));
-  });
+  function getMissingCollectionWBO(next) {
+    _("Testing that fetching a WBO from an on-existent collection 404s.");
+    let req = localRequest(storageURL + "/foobar/baz");
+    req.get(function (err) {
+      do_check_eq(this.response.status, 404);
+      Utils.nextTick(next);
+    });
+  }
+
+  server.start(8080,
+    Async.chain(
+      retrieveWBONotExists,
+      retrieveWBOExists,
+      getStorageFails,
+      getMissingCollectionWBO,
+      deleteStorage,
+      server.stop.bind(server),
+      run_next_test
+    ));
 });
 
 add_test(function test_x_weave_records() {
   let server = new SyncServer();
   server.registerUser("john", "password");
 
   server.createContents("john", {
     crypto: {foos: {foo: "bar"},