diff options
author | louib <louib@users.noreply.github.com> | 2017-09-05 17:28:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-05 17:28:47 +0300 |
commit | 1220b7d5017f4b855110e4459aff2ae26e0f34d1 (patch) | |
tree | be1fb9fbc1be653612ddbca8252fcb469ac1d9f9 /tests/TestGroup.cpp | |
parent | 321d4e9c8717a548630e83077b1e14e41ceef503 (diff) |
Feature : Update entries across groups when merging (#807)
* Feature : Update entries across groups when merging
* Styling
Diffstat (limited to 'tests/TestGroup.cpp')
-rw-r--r-- | tests/TestGroup.cpp | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/tests/TestGroup.cpp b/tests/TestGroup.cpp index 5553feae8..efdcb32e6 100644 --- a/tests/TestGroup.cpp +++ b/tests/TestGroup.cpp @@ -452,123 +452,6 @@ void TestGroup::testCopyCustomIcons() delete dbSource; } -void TestGroup::testMerge() -{ - Group* group1 = new Group(); - group1->setName("group 1"); - Group* group2 = new Group(); - group2->setName("group 2"); - - Entry* entry1 = new Entry(); - Entry* entry2 = new Entry(); - - entry1->setGroup(group1); - entry1->setUuid(Uuid::random()); - entry2->setGroup(group1); - entry2->setUuid(Uuid::random()); - - group2->merge(group1); - - QCOMPARE(group1->entries().size(), 2); - QCOMPARE(group2->entries().size(), 2); -} - -void TestGroup::testMergeDatabase() -{ - Database* dbSource = createMergeTestDatabase(); - Database* dbDest = new Database(); - - dbDest->merge(dbSource); - - QCOMPARE(dbDest->rootGroup()->children().size(), 2); - QCOMPARE(dbDest->rootGroup()->children().at(0)->entries().size(), 2); - - delete dbDest; - delete dbSource; -} - -void TestGroup::testMergeConflict() -{ - Database* dbSource = createMergeTestDatabase(); - - // test merging updated entries - // falls back to KeepBoth mode - Database* dbCopy = new Database(); - dbCopy->setRootGroup(dbSource->rootGroup()->clone(Entry::CloneNoFlags)); - - // sanity check - QCOMPARE(dbCopy->rootGroup()->children().at(0)->entries().size(), 2); - - // make this entry newer than in original db - Entry* updatedEntry = dbCopy->rootGroup()->children().at(0)->entries().at(0); - TimeInfo updatedTimeInfo = updatedEntry->timeInfo(); - updatedTimeInfo.setLastModificationTime(updatedTimeInfo.lastModificationTime().addYears(1)); - updatedEntry->setTimeInfo(updatedTimeInfo); - - dbCopy->merge(dbSource); - - // one entry is duplicated because of mode - QCOMPARE(dbCopy->rootGroup()->children().at(0)->entries().size(), 2); - - delete dbSource; - delete dbCopy; -} - -void TestGroup::testMergeConflictKeepBoth() -{ - Database* dbSource = createMergeTestDatabase(); - - // test merging updated entries - // falls back to KeepBoth mode - Database* dbCopy = new Database(); - dbCopy->setRootGroup(dbSource->rootGroup()->clone(Entry::CloneNoFlags)); - - // sanity check - QCOMPARE(dbCopy->rootGroup()->children().at(0)->entries().size(), 2); - - // make this entry newer than in original db - Entry* updatedEntry = dbCopy->rootGroup()->children().at(0)->entries().at(0); - TimeInfo updatedTimeInfo = updatedEntry->timeInfo(); - updatedTimeInfo.setLastModificationTime(updatedTimeInfo.lastModificationTime().addYears(1)); - updatedEntry->setTimeInfo(updatedTimeInfo); - - dbCopy->rootGroup()->setMergeMode(Group::MergeMode::KeepBoth); - - dbCopy->merge(dbSource); - - // one entry is duplicated because of mode - QCOMPARE(dbCopy->rootGroup()->children().at(0)->entries().size(), 3); - // the older entry was merged from the other db as last in the group - Entry* olderEntry = dbCopy->rootGroup()->children().at(0)->entries().at(2); - QVERIFY2(olderEntry->attributes()->hasKey("merged"), "older entry is marked with an attribute \"merged\""); - - delete dbSource; - delete dbCopy; -} - -Database* TestGroup::createMergeTestDatabase() -{ - Database* db = new Database(); - - Group* group1 = new Group(); - group1->setName("group 1"); - Group* group2 = new Group(); - group2->setName("group 2"); - - Entry* entry1 = new Entry(); - Entry* entry2 = new Entry(); - - entry1->setGroup(group1); - entry1->setUuid(Uuid::random()); - entry2->setGroup(group1); - entry2->setUuid(Uuid::random()); - - group1->setParent(db->rootGroup()); - group2->setParent(db->rootGroup()); - - return db; -} - void TestGroup::testFindEntry() { Database* db = new Database(); |