testing: fixed testInsertTwice
Backends need to declare how they'll react to inserting the same item (= same UID) item twice.
This commit is contained in:
parent
7feed6634a
commit
2673b67981
|
@ -121,6 +121,8 @@ public:
|
|||
|
||||
virtual void updateConfig(ClientTestConfig &config) const
|
||||
{
|
||||
// tell testInsertTwice that we won't detect duplicates
|
||||
config.m_sourceKnowsItemSemantic = false;
|
||||
config.m_type = "file:text/vcard:3.0";
|
||||
}
|
||||
} VCard30Test;
|
||||
|
@ -153,6 +155,7 @@ public:
|
|||
|
||||
virtual void updateConfig(ClientTestConfig &config) const
|
||||
{
|
||||
config.m_sourceKnowsItemSemantic = false;
|
||||
config.m_type = "file:text/calendar:2.0";
|
||||
}
|
||||
} ITodo20Test;
|
||||
|
@ -163,6 +166,7 @@ public:
|
|||
|
||||
virtual void updateConfig(ClientTestConfig &config) const
|
||||
{
|
||||
config.m_sourceKnowsItemSemantic = false;
|
||||
config.m_type = "virtual:text/x-vcalendar";
|
||||
config.m_subConfigs = "file_event,file_task";
|
||||
}
|
||||
|
|
|
@ -45,11 +45,6 @@ class CalDAVSource : public WebDAVSource,
|
|||
virtual void removeMergedItem(const std::string &luid);
|
||||
virtual void flushItem(const string &uid);
|
||||
virtual std::string getSubDescription(const string &uid, const string &subid);
|
||||
virtual void updateSynthesisInfo(SynthesisInfo &info,
|
||||
XMLConfigFragments &fragments) {
|
||||
info.m_backendRule = "HAVE-SYNCEVOLUTION-EXDATE-DETACHED";
|
||||
info.m_globalIDs = true;
|
||||
}
|
||||
|
||||
// implementation of SyncSourceLogging callback
|
||||
virtual std::string getDescription(const string &luid);
|
||||
|
|
|
@ -1188,6 +1188,16 @@ void WebDAVSource::getSynthesisInfo(SynthesisInfo &info,
|
|||
XMLConfigFragments &fragments)
|
||||
{
|
||||
TrackingSyncSource::getSynthesisInfo(info, fragments);
|
||||
|
||||
// only CalDAV enforces unique UID
|
||||
std::string content = getContent();
|
||||
if (content == "VEVENT" || content == "VTODO" || content == "VJOURNAL") {
|
||||
info.m_globalIDs = true;
|
||||
}
|
||||
if (content == "VEVENT") {
|
||||
info.m_backendRule = "HAVE-SYNCEVOLUTION-EXDATE-DETACHED";
|
||||
}
|
||||
|
||||
// TODO: instead of identifying the peer based on the
|
||||
// session URI, use some information gathered about
|
||||
// it during open()
|
||||
|
|
|
@ -255,6 +255,10 @@ public:
|
|||
if (m_type == "caldav") {
|
||||
config.m_supportsReccurenceEXDates = true;
|
||||
}
|
||||
config.m_sourceKnowsItemSemantic =
|
||||
m_type == "caldav" ||
|
||||
m_type == "caldavjournal" ||
|
||||
m_type == "caldavtodo";
|
||||
config.m_createSourceA = boost::bind(&WebDAVTest::createSource, this, _2, _4);
|
||||
config.m_createSourceB = boost::bind(&WebDAVTest::createSource, this, _2, _4);
|
||||
ConfigProps::const_iterator it = m_props.find(m_type + "/testcases");
|
||||
|
|
|
@ -367,6 +367,8 @@ struct ClientTestConfig {
|
|||
* setting this to false disables tests which depend
|
||||
* on the source's support for linked item semantic
|
||||
* (testLinkedItemsInsertParentTwice, testLinkedItemsInsertChildTwice)
|
||||
*
|
||||
* Matches SynthesisInfo::m_globalIDs.
|
||||
*/
|
||||
Bool m_sourceKnowsItemSemantic;
|
||||
|
||||
|
@ -1421,6 +1423,8 @@ class SyncSourceBase : public Logger {
|
|||
* created). If both sides in a sync support this, then the
|
||||
* engine can rely on these properties to find matching items
|
||||
* during a slow sync.
|
||||
*
|
||||
* Matches ClientTestConfig::m_sourceKnowsItemSemantic.
|
||||
*/
|
||||
Bool m_globalIDs;
|
||||
};
|
||||
|
|
|
@ -1124,8 +1124,13 @@ void LocalTests::testInsertTwice() {
|
|||
second.m_state == ITEM_MERGED ? "was merged" :
|
||||
second.m_state == ITEM_OKAY ? "was added, which is broken!" :
|
||||
"unknown result ?!");
|
||||
CT_ASSERT(second.m_state == ITEM_NEEDS_MERGE || second.m_state == ITEM_REPLACED || second.m_state == ITEM_MERGED);
|
||||
CT_ASSERT_EQUAL(first.m_luid, second.m_luid);
|
||||
if (config.m_sourceKnowsItemSemantic) {
|
||||
CT_ASSERT(second.m_state == ITEM_NEEDS_MERGE || second.m_state == ITEM_REPLACED || second.m_state == ITEM_MERGED);
|
||||
CT_ASSERT_EQUAL(first.m_luid, second.m_luid);
|
||||
} else {
|
||||
CT_ASSERT(second.m_state == ITEM_OKAY);
|
||||
CT_ASSERT(first.m_luid != second.m_luid);
|
||||
}
|
||||
if (second.m_state == ITEM_REPLACED || second.m_state == ITEM_MERGED) {
|
||||
CT_ASSERT(first.m_revision != second.m_revision);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue