testing: added another add<->add test
testAddBothSidesRefresh() changes the order of data modifications and syncs so that the sync where the conflict is detected has to send back an update.
This commit is contained in:
parent
2773dfe47d
commit
5e88021226
|
@ -1815,6 +1815,7 @@ void SyncTests::addTests(bool isFirstSource) {
|
|||
config.m_updateItem.find("LAST-MODIFIED:") != std::string::npos &&
|
||||
sources.size() == 1) {
|
||||
ADD_TEST(SyncTests, testAddBothSides);
|
||||
ADD_TEST(SyncTests, testAddBothSidesRefresh);
|
||||
}
|
||||
|
||||
// only add when testing individual source,
|
||||
|
@ -3138,6 +3139,57 @@ void SyncTests::testAddBothSides()
|
|||
CPPUNIT_ASSERT_NO_THROW(copy.reset());
|
||||
}
|
||||
|
||||
/**
|
||||
* compared to testAddBothSides the age of the items is reversed now;
|
||||
* a server which always copies the client's data passes testAddBothSides
|
||||
* but fails here
|
||||
*/
|
||||
void SyncTests::testAddBothSidesRefresh()
|
||||
{
|
||||
deleteAll();
|
||||
accessClientB->deleteAll();
|
||||
|
||||
// insert initial item data on B
|
||||
CPPUNIT_ASSERT_NO_THROW(accessClientB->sources[0].second->insert(accessClientB->sources[0].second->createSourceA,
|
||||
accessClientB->sources[0].second->config.m_insertItem));
|
||||
|
||||
// sleep one second to ensure that it's mangled LAST-MODIFIED is older than
|
||||
// the one from the next item, inserted on A
|
||||
sleep(1);
|
||||
|
||||
// more recent data sent to server first
|
||||
std::string data;
|
||||
CPPUNIT_ASSERT_NO_THROW(sources[0].second->insert(sources[0].second->createSourceA,
|
||||
sources[0].second->config.m_updateItem,
|
||||
false,
|
||||
&data));
|
||||
doSync("send-new",
|
||||
SyncOptions(SYNC_TWO_WAY,
|
||||
CheckSyncReport(0,0,0, 1,0,0, true, SYNC_TWO_WAY)));
|
||||
|
||||
// as far as the client knows, it is adding an item;
|
||||
// server expected to send back an update (it's data was out-dated)
|
||||
accessClientB->doSync("send-old",
|
||||
SyncOptions(SYNC_TWO_WAY,
|
||||
CheckSyncReport(0,1,0, 1,0,0, true, SYNC_TWO_WAY)));
|
||||
|
||||
// update sent to client A (result of merge)
|
||||
doSync("nopA",
|
||||
SyncOptions(SYNC_TWO_WAY,
|
||||
CheckSyncReport(0,1,0, 0,0,0, true, SYNC_TWO_WAY)));
|
||||
|
||||
// nothing necessary for client B (already synchronized completely above in one sync)
|
||||
accessClientB->doSync("nopB",
|
||||
SyncOptions(SYNC_TWO_WAY,
|
||||
CheckSyncReport(0,0,0, 0,0,0, true, SYNC_TWO_WAY)));
|
||||
|
||||
// now compare client A against reference data
|
||||
TestingSyncSourcePtr copy;
|
||||
SOURCE_ASSERT_NO_FAILURE(copy.get(), copy.reset(sources[0].second->createSourceB()));
|
||||
sources[0].second->compareDatabases(*copy, &data, (void *)NULL);
|
||||
CPPUNIT_ASSERT_NO_THROW(copy.reset());
|
||||
}
|
||||
|
||||
/**
|
||||
* - adds parent on client A
|
||||
* - syncs A
|
||||
|
|
|
@ -754,6 +754,7 @@ protected:
|
|||
virtual void testComplexRefreshFromServerSemantic();
|
||||
virtual void testDeleteBothSides();
|
||||
virtual void testAddBothSides();
|
||||
virtual void testAddBothSidesRefresh();
|
||||
virtual void testLinkedItemsParentChild();
|
||||
virtual void testLinkedItemsChild();
|
||||
virtual void testLinkedItemsChildParent();
|
||||
|
|
Loading…
Reference in New Issue