diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-10-06 06:57:51 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-10-06 06:57:51 +0200 |
commit | 0c47c83e1b3b7d95681a43fbb0de0e17b2cd5b25 (patch) | |
tree | c321601f04cbfd02fb6e12878e745dc49a612c86 /services/sync/modules-testing/fakeservices.js | |
parent | 8860eddcee1417483cafd114f3a9ec127e0f1f74 (diff) | |
download | UXP-0c47c83e1b3b7d95681a43fbb0de0e17b2cd5b25.tar UXP-0c47c83e1b3b7d95681a43fbb0de0e17b2cd5b25.tar.gz UXP-0c47c83e1b3b7d95681a43fbb0de0e17b2cd5b25.tar.lz UXP-0c47c83e1b3b7d95681a43fbb0de0e17b2cd5b25.tar.xz UXP-0c47c83e1b3b7d95681a43fbb0de0e17b2cd5b25.zip |
Import Tycho weave client
Diffstat (limited to 'services/sync/modules-testing/fakeservices.js')
-rw-r--r-- | services/sync/modules-testing/fakeservices.js | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/services/sync/modules-testing/fakeservices.js b/services/sync/modules-testing/fakeservices.js index 2895736df..0e265937b 100644 --- a/services/sync/modules-testing/fakeservices.js +++ b/services/sync/modules-testing/fakeservices.js @@ -11,31 +11,17 @@ this.EXPORTED_SYMBOLS = [ "fakeSHA256HMAC", ]; -var {utils: Cu} = Components; +const {utils: Cu} = Components; Cu.import("resource://services-sync/record.js"); Cu.import("resource://services-sync/util.js"); -var btoa = Cu.import("resource://gre/modules/Log.jsm").btoa; +let btoa = Cu.import("resource://gre/modules/Log.jsm").btoa; this.FakeFilesystemService = function FakeFilesystemService(contents) { this.fakeContents = contents; let self = this; - // Save away the unmocked versions of the functions we replace here for tests - // that really want the originals. As this may be called many times per test, - // we must be careful to not replace them with ones we previously replaced. - // (And WTF are we bothering with these mocks in the first place? Is the - // performance of the filesystem *really* such that it outweighs the downside - // of not running our real JSON functions in the tests? Eg, these mocks don't - // always throw exceptions when the real ones do. Anyway...) - for (let name of ["jsonSave", "jsonLoad", "jsonMove", "jsonRemove"]) { - let origName = "_real_" + name; - if (!Utils[origName]) { - Utils[origName] = Utils[name]; - } - } - Utils.jsonSave = function jsonSave(filePath, that, obj, callback) { let json = typeof obj == "function" ? obj.call(that) : obj; self.fakeContents["weave/" + filePath + ".json"] = JSON.stringify(json); @@ -50,18 +36,6 @@ this.FakeFilesystemService = function FakeFilesystemService(contents) { } cb.call(that, obj); }; - - Utils.jsonMove = function jsonMove(aFrom, aTo, that) { - const fromPath = "weave/" + aFrom + ".json"; - self.fakeContents["weave/" + aTo + ".json"] = self.fakeContents[fromPath]; - delete self.fakeContents[fromPath]; - return Promise.resolve(); - }; - - Utils.jsonRemove = function jsonRemove(filePath, that) { - delete self.fakeContents["weave/" + filePath + ".json"]; - return Promise.resolve(); - }; }; this.fakeSHA256HMAC = function fakeSHA256HMAC(message) { @@ -76,9 +50,7 @@ this.FakeGUIDService = function FakeGUIDService() { let latestGUID = 0; Utils.makeGUID = function makeGUID() { - // ensure that this always returns a unique 12 character string - let nextGUID = "fake-guid-" + String(latestGUID++).padStart(2, "0"); - return nextGUID.slice(nextGUID.length-12, nextGUID.length); + return "fake-guid-" + latestGUID++; }; } |