Bug 694657 - Part 0: rename 's' to 'server'. r=philikon
authorRichard Newman <rnewman@mozilla.com>
Sat, 15 Oct 2011 15:29:11 -0700
changeset 78615 9c072e3fa13857e553ddc24e9cb5ecb30ab97aec
parent 78614 cc0be790f8c658ef937981689ec71f066fec3f35
child 78616 8c1ad90b6804312e7866cb733cf12368af4628a4
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 0: rename 's' to 'server'. r=philikon
services/sync/tests/unit/test_httpd_sync_server.js
--- a/services/sync/tests/unit/test_httpd_sync_server.js
+++ b/services/sync/tests/unit/test_httpd_sync_server.js
@@ -1,110 +1,110 @@
 function run_test() {
   Log4Moz.repository.getLogger("Sync.Test.Server").level = Log4Moz.Level.Trace;
   initTestLogging();
   run_next_test();
 }
 
 add_test(function test_creation() {
   // Explicit callback for this one.
-  let s = new SyncServer({
+  let server = new SyncServer({
     __proto__: SyncServerCallback,
   });
-  do_check_true(!!s);       // Just so we have a check.
-  s.start(null, function () {
-    _("Started on " + s.port);
-    s.stop(run_next_test);
+  do_check_true(!!server);       // Just so we have a check.
+  server.start(null, function () {
+    _("Started on " + server.port);
+    server.stop(run_next_test);
   });
 });
 
 add_test(function test_url_parsing() {
-  let s = new SyncServer();
+  let server = new SyncServer();
 
   // Check that we can parse a WBO URI.
-  let parts = s.pathRE.exec("/1.1/johnsmith/storage/crypto/keys");
+  let parts = server.pathRE.exec("/1.1/johnsmith/storage/crypto/keys");
   let [all, version, username, first, rest] = parts;
   do_check_eq(all, "/1.1/johnsmith/storage/crypto/keys");
   do_check_eq(version, "1.1");
   do_check_eq(username, "johnsmith");
   do_check_eq(first, "storage");
   do_check_eq(rest, "crypto/keys");
-  do_check_eq(null, s.pathRE.exec("/nothing/else"));
+  do_check_eq(null, server.pathRE.exec("/nothing/else"));
 
   // Check that we can parse a collection URI.
-  parts = s.pathRE.exec("/1.1/johnsmith/storage/crypto");
+  parts = server.pathRE.exec("/1.1/johnsmith/storage/crypto");
   let [all, version, username, first, rest] = parts;
   do_check_eq(all, "/1.1/johnsmith/storage/crypto");
   do_check_eq(version, "1.1");
   do_check_eq(username, "johnsmith");
   do_check_eq(first, "storage");
   do_check_eq(rest, "crypto");
 
   // We don't allow trailing slash on storage URI.
-  parts = s.pathRE.exec("/1.1/johnsmith/storage/");
+  parts = server.pathRE.exec("/1.1/johnsmith/storage/");
   do_check_eq(parts, undefined);
 
   // storage alone is a valid request.
-  parts = s.pathRE.exec("/1.1/johnsmith/storage");
+  parts = server.pathRE.exec("/1.1/johnsmith/storage");
   let [all, version, username, first, rest] = parts;
   do_check_eq(all, "/1.1/johnsmith/storage");
   do_check_eq(version, "1.1");
   do_check_eq(username, "johnsmith");
   do_check_eq(first, "storage");
   do_check_eq(rest, undefined);
 
-  parts = s.storageRE.exec("storage");
+  parts = server.storageRE.exec("storage");
   let [all, storage, collection, id] = parts;
   do_check_eq(all, "storage");
   do_check_eq(collection, undefined);
 
   run_next_test();
 });
 
 Cu.import("resource://services-sync/rest.js");
 function localRequest(path) {
   _("localRequest: " + path);
   let url = "http://127.0.0.1:8080" + path;
   _("url: " + url);
   return new RESTRequest(url);
 }
 
 add_test(function test_basic_http() {
-  let s = new SyncServer();
-  s.registerUser("john", "password");
-  do_check_true(s.userExists("john"));
-  s.start(8080, function () {
-    _("Started on " + s.port);
-    do_check_eq(s.port, 8080);
+  let server = new SyncServer();
+  server.registerUser("john", "password");
+  do_check_true(server.userExists("john"));
+  server.start(8080, function () {
+    _("Started on " + server.port);
+    do_check_eq(server.port, 8080);
     Utils.nextTick(function () {
       let req = localRequest("/1.1/john/storage/crypto/keys");
       _("req is " + req);
       req.get(function (err) {
         do_check_eq(null, err);
         Utils.nextTick(function () {
-          s.stop(run_next_test);
+          server.stop(run_next_test);
         });
       });
     });
   });
 });
 
 add_test(function test_info_collections() {
-  let s = new SyncServer({
+  let server = new SyncServer({
     __proto__: SyncServerCallback
   });
   function responseHasCorrectHeaders(r) {
     do_check_eq(r.status, 200);
     do_check_eq(r.headers["content-type"], "application/json");
     do_check_true("x-weave-timestamp" in r.headers);
   }
 
-  s.registerUser("john", "password");
-  s.start(8080, function () {
-    do_check_eq(s.port, 8080);
+  server.registerUser("john", "password");
+  server.start(8080, function () {
+    do_check_eq(server.port, 8080);
     Utils.nextTick(function () {
       let req = localRequest("/1.1/john/info/collections");
       req.get(function (err) {
         // Initial info/collections fetch is empty.
         do_check_eq(null, err);
         responseHasCorrectHeaders(this.response);
 
         do_check_eq(this.response.body, "{}");
@@ -115,48 +115,48 @@ add_test(function test_info_collections(
             responseHasCorrectHeaders(this.response);
             let putResponseBody = this.response.body;
             _("PUT response body: " + JSON.stringify(putResponseBody));
 
             req = localRequest("/1.1/john/info/collections");
             req.get(function (err) {
               do_check_eq(null, err);
               responseHasCorrectHeaders(this.response);
-              let expectedColl = s.getCollection("john", "crypto");
+              let expectedColl = server.getCollection("john", "crypto");
               do_check_true(!!expectedColl);
               let modified = expectedColl.timestamp;
               do_check_true(modified > 0);
               do_check_eq(putResponseBody, modified);
               do_check_eq(JSON.parse(this.response.body).crypto, modified);
               Utils.nextTick(function () {
-                s.stop(run_next_test);
+                server.stop(run_next_test);
               });
             });
           }
           let payload = JSON.stringify({foo: "bar"});
           localRequest("/1.1/john/storage/crypto/keys").put(payload, cb);
         });
       });
     });
   });
 });
 
 add_test(function test_storage_request() {
   let keysURL = "/1.1/john/storage/crypto/keys?foo=bar";
   let foosURL = "/1.1/john/storage/crypto/foos";
   let storageURL = "/1.1/john/storage";
 
-  let s = new SyncServer();
-  let creation = s.timestamp();
-  s.registerUser("john", "password");
+  let server = new SyncServer();
+  let creation = server.timestamp();
+  server.registerUser("john", "password");
 
-  s.createContents("john", {
+  server.createContents("john", {
     crypto: {foos: {foo: "bar"}}
   });
-  let coll = s.user("john").collection("crypto");
+  let coll = server.user("john").collection("crypto");
   do_check_true(!!coll);
 
   _("We're tracking timestamps.");
   do_check_true(coll.timestamp >= creation);
 
   function retrieveWBONotExists(next) {
     let req = localRequest(keysURL);
     req.get(function (err) {
@@ -177,61 +177,61 @@ add_test(function test_storage_request()
       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 deleteStorage(next) {
     _("Testing DELETE on /storage.");
-    let now = s.timestamp();
+    let now = server.timestamp();
     _("Timestamp: " + now);
     let req = localRequest(storageURL);
     req.delete(function (err) {
       _("Body is " + this.response.body);
       _("Modified is " + this.response.newModified);
       let parsedBody = JSON.parse(this.response.body);
       do_check_true(parsedBody >= now);
-      do_check_empty(s.users["john"].collections);
+      do_check_empty(server.users["john"].collections);
       Utils.nextTick(next);
     });
   }
   function getStorageFails(next) {
     _("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);
     });
   }
-  s.start(8080, function () {
+  server.start(8080, function () {
     retrieveWBONotExists(
       retrieveWBOExists.bind(this,
         getStorageFails.bind(this,
           deleteStorage.bind(this, function () {
-            s.stop(run_next_test);
+            server.stop(run_next_test);
           }))));
   });
 });
 
 add_test(function test_x_weave_records() {
-  let s = new SyncServer();
-  s.registerUser("john", "password");
+  let server = new SyncServer();
+  server.registerUser("john", "password");
 
-  s.createContents("john", {
+  server.createContents("john", {
     crypto: {foos: {foo: "bar"},
              bars: {foo: "baz"}}
   });
-  s.start(8080, function () {
+  server.start(8080, function () {
     let wbo = localRequest("/1.1/john/storage/crypto/foos");
     wbo.get(function (err) {
       // WBO fetches don't have one.
       do_check_false("x-weave-records" in this.response.headers);
       let col = localRequest("/1.1/john/storage/crypto");
       col.get(function (err) {
         // Collection fetches do.
         do_check_eq(this.response.headers["x-weave-records"], "2");
-        s.stop(run_next_test);
+        server.stop(run_next_test);
       });
     });
   });
 });