From 4c1fcc3c2bab23c84f30c9e8fe52eeb6e1311818 Mon Sep 17 00:00:00 2001 From: Atul Varma Date: Tue, 24 Jun 2008 16:55:56 -0700 Subject: [PATCH] Added a really, really basic sync test for bookmarks. --- services/sync/tests/unit/head_first.js | 3 +- .../sync/tests/unit/test_bookmark_syncing.js | 18 +++++++ .../unit/test_bookmark_syncing.log.expected | 47 +++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 services/sync/tests/unit/test_bookmark_syncing.js create mode 100644 services/sync/tests/unit/test_bookmark_syncing.log.expected diff --git a/services/sync/tests/unit/head_first.js b/services/sync/tests/unit/head_first.js index 2e55b348b0a..1ab0c3db674 100644 --- a/services/sync/tests/unit/head_first.js +++ b/services/sync/tests/unit/head_first.js @@ -284,7 +284,8 @@ function SyncTestingInfrastructure() { "encryption" : "none", "log.logger.service.crypto" : "Debug", "log.logger.service.engine" : "Debug", - "log.logger.async" : "Debug" + "log.logger.async" : "Debug", + "xmpp.enabled" : false }; Cu.import("resource://weave/identity.js"); diff --git a/services/sync/tests/unit/test_bookmark_syncing.js b/services/sync/tests/unit/test_bookmark_syncing.js new file mode 100644 index 00000000000..4a3319ff256 --- /dev/null +++ b/services/sync/tests/unit/test_bookmark_syncing.js @@ -0,0 +1,18 @@ +Cu.import("resource://weave/engines/bookmarks.js"); + +// ---------------------------------------- +// Test Logic +// ---------------------------------------- + +function run_test() { + var syncTesting = new SyncTestingInfrastructure(); + + function freshEngineSync(cb) { + let engine = new BookmarksEngine(); + engine.sync(cb); + }; + + syncTesting.runAsyncFunc("initial sync", freshEngineSync); + + syncTesting.runAsyncFunc("trivial re-sync", freshEngineSync); +} diff --git a/services/sync/tests/unit/test_bookmark_syncing.log.expected b/services/sync/tests/unit/test_bookmark_syncing.log.expected new file mode 100644 index 00000000000..775c0d80dfa --- /dev/null +++ b/services/sync/tests/unit/test_bookmark_syncing.log.expected @@ -0,0 +1,47 @@ +*** test pending +Testing INFO ----------------------------------------- +Testing INFO Step 'initial sync' starting. +Testing INFO ----------------------------------------- +Service.BmkEngine INFO Beginning sync +Testing INFO HTTP MKCOL on user-data/bookmarks/deltas +Service.RemoteStore DEBUG Downloading status file +Testing INFO HTTP GET from user-data/bookmarks/status.json, returning status 404 +Service.BmkEngine INFO Initial upload to server +Service.JsonFilter DEBUG Encoding data as JSON +Testing INFO HTTP PUT to user-data/bookmarks/keys.json with data: {"ring":{},"bulkIV":null} +Service.Resource DEBUG PUT request successful +Service.JsonFilter DEBUG Encoding data as JSON +Service.CryptoFilter DEBUG Encrypting data +Service.Crypto DEBUG NOT encrypting data +Testing INFO HTTP PUT to user-data/bookmarks/snapshot.json with data: {"menu":{"type":"folder"},"toolbar":{"type":"folder"},"unfiled":{"type":"folder"}} +Service.Resource DEBUG PUT request successful +Service.JsonFilter DEBUG Encoding data as JSON +Testing INFO HTTP PUT to user-data/bookmarks/status.json with data: {"GUID":"fake-guid-0","formatVersion":2,"snapVersion":0,"maxVersion":0,"snapEncryption":"none","deltasEncryption":"none","itemCount":3} +Service.Resource DEBUG PUT request successful +Service.RemoteStore INFO Full upload to server successful +Service.SnapStore INFO Saving snapshot to disk +Testing INFO Opening 'weave/snapshots/bookmarks.json' for writing. +Testing INFO Writing data to local file 'weave/snapshots/bookmarks.json': {"version":0,"GUID":"fake-guid-0","snapshot":{"menu":{"type":"folder"},"toolbar":{"type":"folder"},"unfiled":{"type":"folder"}}} +Testing INFO Step 'initial sync' succeeded. +Testing INFO ----------------------------------------- +Testing INFO Step 'trivial re-sync' starting. +Testing INFO ----------------------------------------- +Testing INFO Opening 'weave/snapshots/bookmarks.json' for reading. +Testing INFO Reading from stream. +Service.SnapStore INFO Read saved snapshot from disk +Service.BmkEngine INFO Beginning sync +Testing INFO HTTP MKCOL on user-data/bookmarks/deltas +Service.RemoteStore DEBUG Downloading status file +Testing INFO HTTP GET from user-data/bookmarks/status.json, returning status 200 +Service.Resource DEBUG GET request successful +Service.JsonFilter DEBUG Decoding JSON data +Service.RemoteStore DEBUG Downloading status file... done +Service.BmkEngine INFO Local snapshot version: 0 +Service.BmkEngine INFO Server maxVersion: 0 +Service.RemoteStore DEBUG Using last sync snapshot as server snapshot (snap version == max version) +Service.RemoteStore TRACE Local snapshot version == server maxVersion +Service.BmkEngine INFO Sync complete: no changes needed on client or server +Testing INFO Step 'trivial re-sync' succeeded. +*** test finished +*** exiting +*** PASS ***