forked from organicmaps/organicmaps
[ugc] Added test for empty index file and additional error logging.
This commit is contained in:
parent
5d939192f9
commit
4cc87e8430
2 changed files with 20 additions and 1 deletions
|
@ -22,6 +22,7 @@
|
|||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "3party/Alohalytics/src/alohalytics.h"
|
||||
#include "3party/jansson/myjansson.hpp"
|
||||
|
||||
#include <boost/optional/optional.hpp>
|
||||
|
@ -212,7 +213,13 @@ void Storage::Load()
|
|||
return;
|
||||
}
|
||||
|
||||
CHECK(!data.empty(), ());
|
||||
if (data.empty())
|
||||
{
|
||||
ASSERT(false, ());
|
||||
alohalytics::Stats::Instance().LogEvent("UGC_File_error", {{"error", "empty index file"}});
|
||||
return;
|
||||
}
|
||||
|
||||
DeserializeIndexes(data, m_indexes);
|
||||
if (m_indexes.empty())
|
||||
return;
|
||||
|
@ -398,6 +405,7 @@ size_t Storage::GetNumberOfUnsynchronized() const
|
|||
if (!i.m_deleted && !i.m_synchronized)
|
||||
++numberOfUnsynchronized;
|
||||
}
|
||||
|
||||
return numberOfUnsynchronized;
|
||||
}
|
||||
|
||||
|
|
|
@ -478,3 +478,14 @@ UNIT_TEST(UGC_IndexMigrationFromV0ToV1Smoke)
|
|||
my::DeleteFileX(indexFilePath);
|
||||
my::DeleteFileX(v0IndexFilePath);
|
||||
}
|
||||
|
||||
UNIT_TEST(UGC_NoReviews)
|
||||
{
|
||||
auto & builder = MwmBuilder::Builder();
|
||||
Storage s(builder.GetDataSource());
|
||||
s.Load();
|
||||
s.SaveIndex();
|
||||
// When we didn't write any reviews there should be no index file and no ugc file.
|
||||
TEST(!DeleteIndexFile(), ());
|
||||
TEST(!DeleteUGCFile(), ());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue