Implemented DELETE and listFiles on fake DAV so that test_service doesn't raise an exception.
authorAtul Varma <varmaa@toolness.com>
Thu, 26 Jun 2008 17:48:39 -0700
changeset 44796 57565c7b685965ffcd9037d41fc8f05b3516b277
parent 44795 2cb80d091bdf49a0254a46cdbcd714a26e36374a
child 44797 9b0afda36feaf6516de5e53ab0ddb311bb98296e
push idunknown
push userunknown
push dateunknown
Implemented DELETE and listFiles on fake DAV so that test_service doesn't raise an exception.
services/sync/tests/unit/head_first.js
--- a/services/sync/tests/unit/head_first.js
+++ b/services/sync/tests/unit/head_first.js
@@ -190,16 +190,39 @@ FakeDAVService.prototype = {
     getTestLogger().info("HTTP GET from " + path + ", returning status " +
                          result.status);
     return makeFakeAsyncFunc(result).async(this, onComplete);
   },
 
   MKCOL: function fake_MKCOL(path, onComplete) {
     getTestLogger().info("HTTP MKCOL on " + path);
     makeFakeAsyncFunc(true).async(this, onComplete);
+  },
+
+  DELETE: function fake_DELETE(path, onComplete) {
+    var result = {status: 404};
+    if (path in this.fakeContents) {
+      result = {status: 200};
+      delete this.fakeContents[path];
+    }
+    getTestLogger().info("HTTP DELETE on " + path + ", returning status " +
+                         result.status);
+    return makeFakeAsyncFunc(result).async(this, onComplete);
+  },
+
+  listFiles: function fake_listFiles(path) {
+    let self = yield;
+    if (typeof(path) != "undefined")
+      throw new Error("Not yet implemented!");
+    let filenames = [];
+    for (name in this.fakeContents) {
+      getTestLogger().info("file " + name);
+      filenames.push(name);
+    }
+    self.done(filenames);
   }
 };
 
 function FakePasswordService(contents) {
   Cu.import("resource://weave/util.js");
 
   this.fakeContents = contents;
   let self = this;