Convert test_records_wbo to sync.
authorEdward Lee <edilee@mozilla.com>
Tue, 09 Jun 2009 14:28:37 -0500
changeset 45549 d03bfe270896942e329c284c5f5fdf32fcb40bb4
parent 45548 570d60a0f6a6bdfc77d1614611fc73793dc524ee
child 45550 96abc2c83eb8398fbc9b0a36f4f68e0ebef66f80
push id14033
push useredward.lee@engineering.uiuc.edu
push dateWed, 23 Jun 2010 22:21:35 +0000
treeherdermozilla-central@227db4ad8cdf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
Convert test_records_wbo to sync.
services/sync/tests/unit/test_records_wbo.js
--- a/services/sync/tests/unit/test_records_wbo.js
+++ b/services/sync/tests/unit/test_records_wbo.js
@@ -1,21 +1,18 @@
 try {
   Cu.import("resource://weave/log4moz.js");
   Cu.import("resource://weave/util.js");
-  Cu.import("resource://weave/async.js");
   Cu.import("resource://weave/auth.js");
   Cu.import("resource://weave/identity.js");
   Cu.import("resource://weave/resource.js");
   Cu.import("resource://weave/base_records/wbo.js");
   Cu.import("resource://weave/base_records/collection.js");
 } catch (e) { do_throw(e); }
 
-Function.prototype.async = Async.sugar;
-
 function record_handler(metadata, response) {
   let obj = {id: "asdf-1234-asdf-1234",
              modified: 2454725.98283,
              payload: JSON.stringify({cheese: "roquefort"})};
   return httpd_basic_auth_handler(JSON.stringify(obj), metadata, response);
 }
 
 function record_handler2(metadata, response) {
@@ -27,18 +24,17 @@ function record_handler2(metadata, respo
 
 function coll_handler(metadata, response) {
   let obj = [{id: "record2",
               modified: 2454725.98284,
               payload: JSON.stringify({cheese: "gruyere"})}];
   return httpd_basic_auth_handler(JSON.stringify(obj), metadata, response);
 }
 
-function async_test() {
-  let self = yield;
+function run_test() {
   let server;
 
   try {
     let log = Log4Moz.repository.getLogger('Test');
     Log4Moz.repository.rootLogger.addAppender(new Log4Moz.DumpAppender());
 
     log.info("Setting up server and authenticator");
 
@@ -47,56 +43,48 @@ function async_test() {
                           "/coll": coll_handler});
 
     let auth = new BasicAuthenticator(new Identity("secret", "guest", "guest"));
     Auth.defaultAuthenticator = auth;
 
     log.info("Getting a WBO record");
 
     let res = new Resource("http://localhost:8080/record");
-    yield res.get(self.cb);
+    res.get();
 
     let rec = new WBORecord();
     rec.deserialize(res.data);
     do_check_eq(rec.id, "asdf-1234-asdf-1234"); // NOT "record"!
 
     rec.uri = res.uri;
     do_check_eq(rec.id, "record"); // NOT "asdf-1234-asdf-1234"!
 
     do_check_eq(rec.modified, 2454725.98283);
     do_check_eq(typeof(rec.payload), "object");
     do_check_eq(rec.payload.cheese, "roquefort");
     do_check_eq(res.lastChannel.responseStatus, 200);
 
     log.info("Getting a WBO record using the record manager");
 
-    let rec2 = yield Records.get(self.cb, "http://localhost:8080/record2");
+    let rec2 = Records.get("http://localhost:8080/record2");
     do_check_eq(rec2.id, "record2");
     do_check_eq(rec2.modified, 2454725.98284);
     do_check_eq(typeof(rec2.payload), "object");
     do_check_eq(rec2.payload.cheese, "gruyere");
     do_check_eq(Records.lastResource.lastChannel.responseStatus, 200);
 
     log.info("Using a collection to get a record");
 
     let coll = new Collection("http://localhost:8080/coll", WBORecord);
-    yield coll.get(self.cb);
+    coll.get();
     do_check_eq(coll.iter.count, 1);
 
-    let rec3 = yield coll.iter.next(self.cb);
+    let rec3 = coll.iter.next();
     do_check_eq(rec3.id, "record2");
     do_check_eq(rec3.modified, 2454725.98284);
     do_check_eq(typeof(rec3.payload), "object");
     do_check_eq(rec3.payload.cheese, "gruyere");
 
     log.info("Done!");
-    do_test_finished();
   }
   catch (e) { do_throw(e); }
   finally { server.stop(); }
-
-  self.done();
 }
-
-function run_test() {
-  async_test.async(this);
-  do_test_pending();
-}