Bug 1317667 - Use dates further in the future in test_bookmark_duping. r=kitcambridge, a=test-only
authorEdouard Oger <eoger@fastmail.com>
Mon, 27 Feb 2017 11:44:22 -0500
changeset 376507 514641af5ac48af57a8d2afef1141a06928be9b5
parent 376506 fd1a80b2522dae0c0aa61d0e7338ea79f9a9ac9a
child 376508 22452940b671ae071bcf3d6bec1bdd238317f8cb
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskitcambridge, test-only
bugs1317667
milestone53.0a2
Bug 1317667 - Use dates further in the future in test_bookmark_duping. r=kitcambridge, a=test-only MozReview-Commit-ID: 3R3tbbzio2I
services/sync/tests/unit/test_bookmark_duping.js
--- a/services/sync/tests/unit/test_bookmark_duping.js
+++ b/services/sync/tests/unit/test_bookmark_duping.js
@@ -154,17 +154,17 @@ add_task(async function test_dupe_bookma
       id: newGUID,
       bmkUri: "http://getfirefox.com/",
       type: "bookmark",
       title: "Get Firefox!",
       parentName: "Folder 1",
       parentid: folder1_guid,
     };
 
-    collection.insert(newGUID, encryptPayload(to_apply), Date.now() / 1000 + 10);
+    collection.insert(newGUID, encryptPayload(to_apply), Date.now() / 1000 + 500);
     _("Syncing so new dupe record is processed");
     engine.lastSync = engine.lastSync - 0.01;
     engine.sync();
 
     // We should have logically deleted the dupe record.
     equal(collection.count(), 7);
     ok(getServerRecord(collection, bmk1_guid).deleted);
     // and physically removed from the local store.
@@ -211,17 +211,17 @@ add_task(async function test_dupe_repare
       id: newGUID,
       bmkUri: "http://getfirefox.com/",
       type: "bookmark",
       title: "Get Firefox!",
       parentName: "Folder 1",
       parentid: folder2_guid,
     };
 
-    collection.insert(newGUID, encryptPayload(to_apply), Date.now() / 1000 + 10);
+    collection.insert(newGUID, encryptPayload(to_apply), Date.now() / 1000 + 500);
 
     _("Syncing so new dupe record is processed");
     engine.lastSync = engine.lastSync - 0.01;
     engine.sync();
 
     // We should have logically deleted the dupe record.
     equal(collection.count(), 8);
     ok(getServerRecord(collection, bmk1_guid).deleted);
@@ -277,26 +277,27 @@ add_task(async function test_dupe_repare
       id: newGUID,
       bmkUri: "http://getfirefox.com/",
       type: "bookmark",
       title: "Get Firefox!",
       parentName: "Folder 1",
       parentid: folder2_guid,
     };
 
-    collection.insert(newGUID, encryptPayload(to_apply), Date.now() / 1000 + 10);
+    let deltaSeconds = 500;
+    collection.insert(newGUID, encryptPayload(to_apply), Date.now() / 1000 + deltaSeconds);
 
     // Make a change to the bookmark that's a dupe, and set the modification
     // time further in the future than the incoming record. This will cause
     // us to issue the infamous "DATA LOSS" warning in the logs but cause us
     // to *not* apply the incoming record.
     await PlacesTestUtils.setBookmarkSyncFields({
       guid: bmk1_guid,
       syncChangeCounter: 1,
-      lastModified: Date.now() + 60000,
+      lastModified: Date.now() + (deltaSeconds + 10) * 1000,
     });
 
     _("Syncing so new dupe record is processed");
     engine.lastSync = engine.lastSync - 0.01;
     engine.sync();
 
     // We should have logically deleted the dupe record.
     equal(collection.count(), 8);
@@ -353,41 +354,41 @@ add_task(async function test_dupe_repare
     collection.insert(newParentGUID, encryptPayload({
       id: newParentGUID,
       type: "folder",
       title: "Folder 1",
       parentName: "A second folder",
       parentid: folder2_guid,
       children: [newGUID],
       tags: [],
-    }), Date.now() / 1000 + 10);
+    }), Date.now() / 1000 + 500);
 
     // And also the update to "folder 2" that references the new parent.
     collection.insert(folder2_guid, encryptPayload({
       id: folder2_guid,
       type: "folder",
       title: "A second folder",
       parentName: "Bookmarks Toolbar",
       parentid: "toolbar",
       children: [newParentGUID],
       tags: [],
-    }), Date.now() / 1000 + 10);
+    }), Date.now() / 1000 + 500);
 
     // Now create a new incoming record that looks alot like a dupe of the
     // item in folder1_guid, with a record that points to a parent with the
     // same name which appeared earlier in this sync.
     collection.insert(newGUID, encryptPayload({
       id: newGUID,
       bmkUri: "http://getfirefox.com/",
       type: "bookmark",
       title: "Get Firefox!",
       parentName: "Folder 1",
       parentid: newParentGUID,
       tags: [],
-    }), Date.now() / 1000 + 10);
+    }), Date.now() / 1000 + 500);
 
 
     _("Syncing so new records are processed.");
     engine.lastSync = engine.lastSync - 0.01;
     engine.sync();
 
     // Everything should be parented correctly.
     equal((await getFolderChildrenIDs(folder1_id)).length, 0);
@@ -432,39 +433,39 @@ add_task(async function test_dupe_repare
     collection.insert(newGUID, encryptPayload({
       id: newGUID,
       bmkUri: "http://getfirefox.com/",
       type: "bookmark",
       title: "Get Firefox!",
       parentName: "Folder 1",
       parentid: newParentGUID,
       tags: [],
-    }), Date.now() / 1000 + 10);
+    }), Date.now() / 1000 + 500);
 
     // Now have the parent appear after (so when the record above is processed
     // this is still unknown.)
     collection.insert(newParentGUID, encryptPayload({
       id: newParentGUID,
       type: "folder",
       title: "Folder 1",
       parentName: "A second folder",
       parentid: folder2_guid,
       children: [newGUID],
       tags: [],
-    }), Date.now() / 1000 + 10);
+    }), Date.now() / 1000 + 500);
     // And also the update to "folder 2" that references the new parent.
     collection.insert(folder2_guid, encryptPayload({
       id: folder2_guid,
       type: "folder",
       title: "A second folder",
       parentName: "Bookmarks Toolbar",
       parentid: "toolbar",
       children: [newParentGUID],
       tags: [],
-    }), Date.now() / 1000 + 10);
+    }), Date.now() / 1000 + 500);
 
     _("Syncing so out-of-order records are processed.");
     engine.lastSync = engine.lastSync - 0.01;
     engine.sync();
 
     // The intended parent did end up existing, so it should be parented
     // correctly after de-duplication.
     equal((await getFolderChildrenIDs(folder1_id)).length, 0);
@@ -509,17 +510,17 @@ add_task(async function test_dupe_repare
     collection.insert(newGUID, encryptPayload({
       id: newGUID,
       bmkUri: "http://getfirefox.com/",
       type: "bookmark",
       title: "Get Firefox!",
       parentName: "Folder 1",
       parentid: newParentGUID,
       tags: [],
-    }), Date.now() / 1000 + 10);
+    }), Date.now() / 1000 + 500);
 
     _("Syncing so new dupe record is processed");
     engine.lastSync = engine.lastSync - 0.01;
     engine.sync();
 
     // We should have logically deleted the dupe record.
     equal(collection.count(), 8);
     ok(getServerRecord(collection, bmk1_guid).deleted);
@@ -552,27 +553,27 @@ add_task(async function test_dupe_repare
     collection.insert(newParentGUID, encryptPayload({
       id: newParentGUID,
       type: "folder",
       title: "Folder 1",
       parentName: "A second folder",
       parentid: folder2_guid,
       children: [newGUID],
       tags: [],
-    }), Date.now() / 1000 + 10);
+    }), Date.now() / 1000 + 500);
     // We also queue an update to "folder 2" that references the new parent.
     collection.insert(folder2_guid, encryptPayload({
       id: folder2_guid,
       type: "folder",
       title: "A second folder",
       parentName: "Bookmarks Toolbar",
       parentid: "toolbar",
       children: [newParentGUID],
       tags: [],
-    }), Date.now() / 1000 + 10);
+    }), Date.now() / 1000 + 500);
 
     _("Syncing so missing parent appears");
     engine.lastSync = engine.lastSync - 0.01;
     engine.sync();
 
     // The intended parent now does exist, so it should have been reparented.
     equal((await getFolderChildrenIDs(folder1_id)).length, 0);
     let newParentID = store.idForGUID(newParentGUID);
@@ -618,17 +619,17 @@ add_task(async function test_dupe_empty_
     let newFolderGUID = Utils.makeGUID();
     collection.insert(newFolderGUID, encryptPayload({
       id: newFolderGUID,
       type: "folder",
       title: "Folder 1",
       parentName: "Bookmarks Toolbar",
       parentid: "toolbar",
       children: [],
-    }), Date.now() / 1000 + 10);
+    }), Date.now() / 1000 + 500);
 
     _("Syncing so new dupe records are processed");
     engine.lastSync = engine.lastSync - 0.01;
     engine.sync();
 
     await validate(collection);
 
     // Collection now has one additional record - the logically deleted dupe.