Bug 694744 - Typo in JS Sync server. r=philikon
authorRichard Newman <rnewman@mozilla.com>
Sat, 15 Oct 2011 15:29:11 -0700
changeset 79071 d9281069d6b824361e8a772e5d18edb9b21faf29
parent 79070 8c1ad90b6804312e7866cb733cf12368af4628a4
child 79072 47950c8ae523664dc1d170fff85c99fec14bcaa6
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersphilikon
bugs694744
milestone10.0a1
Bug 694744 - Typo in JS Sync server. 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
@@ -901,19 +901,19 @@ SyncServer.prototype = {
           if (!coll) {
             respond(200, "OK", "{}");
             return;
           }
           if (wboID) {
             let wbo = coll.wbo(wboID);
             if (wbo) {
               wbo.delete();
+              this.callback.onItemDeleted(username, collection, wboID);
             }
             respond(200, "OK", "{}");
-            this.callback.onItemDeleted(username, collectin, wboID);
             return;
           }
           coll.collectionHandler(req, resp);
 
           // Spot if this is a DELETE for some IDs, and don't blow away the
           // whole collection!
           //
           // We already handled deleting the WBOs by invoking the deleted
--- a/services/sync/tests/unit/test_httpd_sync_server.js
+++ b/services/sync/tests/unit/test_httpd_sync_server.js
@@ -175,16 +175,47 @@ add_test(function test_storage_request()
       _("Modified is " + this.response.newModified);
       let parsedBody = JSON.parse(this.response.body);
       do_check_eq(parsedBody.id, "foos");
       do_check_eq(parsedBody.modified, coll.wbo("foos").modified);
       do_check_eq(JSON.parse(parsedBody.payload).foo, "bar");
       Utils.nextTick(next);
     });
   }
+  function deleteWBONotExists(next) {
+    let req = localRequest(keysURL);
+    server.callback.onItemDeleted = function (username, collection, wboID) {
+      do_throw("onItemDeleted should not have been called.");
+    };
+      
+    req.delete(function (err) {
+      _("Body is " + this.response.body);
+      _("Modified is " + this.response.newModified);
+      do_check_eq(this.response.status, 200);
+      delete server.callback.onItemDeleted;
+      Utils.nextTick(next);
+    });
+  }
+  function deleteWBOExists(next) {
+    let req = localRequest(foosURL);
+    server.callback.onItemDeleted = function (username, collection, wboID) {
+      _("onItemDeleted called for " + collection + "/" + wboID);
+      delete server.callback.onItemDeleted;
+      do_check_eq(username, "john");
+      do_check_eq(collection, "crypto");
+      do_check_eq(wboID, "foos");
+      Utils.nextTick(next);
+    };
+      
+    req.delete(function (err) {
+      _("Body is " + this.response.body);
+      _("Modified is " + this.response.newModified);
+      do_check_eq(this.response.status, 200);
+    });
+  }
   function deleteStorage(next) {
     _("Testing DELETE on /storage.");
     let now = server.timestamp();
     _("Timestamp: " + now);
     let req = localRequest(storageURL);
     req.delete(function (err) {
       _("Body is " + this.response.body);
       _("Modified is " + this.response.newModified);
@@ -211,16 +242,18 @@ add_test(function test_storage_request()
       Utils.nextTick(next);
     });
   }
 
   server.start(8080,
     Async.chain(
       retrieveWBONotExists,
       retrieveWBOExists,
+      deleteWBOExists,
+      deleteWBONotExists,
       getStorageFails,
       getMissingCollectionWBO,
       deleteStorage,
       server.stop.bind(server),
       run_next_test
     ));
 });