[core] Introduce OfflineDatabase::runPackDatabaseAutomatically() API

- added a unit test
- Updated inline comments in default_file_source.hpp
This commit is contained in:
Mikhail Pozdnyakov
2019-11-25 12:18:32 +02:00
parent 0ec01356d8
commit 4c49f0c9db
6 changed files with 76 additions and 52 deletions

View File

@@ -701,7 +701,8 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DeleteRegion)) {
db.putRegionResources(region2->getID(), generateResources("mapbox://tile_2", "mapbox://style_2"), status);
const size_t sizeWithTwoRegions = util::read_file(filename).size();
db.deleteRegion(std::move(*region1), false /*pack*/);
db.runPackDatabaseAutomatically(false);
db.deleteRegion(std::move(*region1));
ASSERT_EQ(1u, db.listRegions().value().size());
// Region is removed but the size of the database is the same.
@@ -711,7 +712,7 @@ TEST(OfflineDatabase, TEST_REQUIRES_WRITE(DeleteRegion)) {
// The size of the database has shrunk after pack().
const size_t sizeWithOneRegion = util::read_file(filename).size();
EXPECT_LT(sizeWithOneRegion, sizeWithTwoRegions);
db.runPackDatabaseAutomatically(true);
db.deleteRegion(std::move(*region2));
// The size of the database has shrunk right away.
const size_t sizeWithoutRegions = util::read_file(filename).size();