Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Commit

Permalink
Test cache::do_vacuum
Browse files Browse the repository at this point in the history
  • Loading branch information
Minoru committed Oct 23, 2016
1 parent 25339a6 commit bf4e1b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ void cache::delete_item(const std::shared_ptr<rss_item> item) {

void cache::do_vacuum() {
std::lock_guard<std::mutex> lock(mtx);
run_sql_nothrow("VACUUM;");
run_sql("VACUUM;");
}

void cache::cleanup_cache(std::vector<std::shared_ptr<rss_feed>>& feeds) {
Expand Down
14 changes: 14 additions & 0 deletions test/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,3 +777,17 @@ TEST_CASE("externalize_rssfeed resets \"unread\" field if item's content changed
REQUIRE(feed->items()[0]->unread());
}
}

TEST_CASE("do_vacuum doesn't throw an exception") {
TestHelpers::TempFile dbfile;
configcontainer cfg;
std::unique_ptr<cache> rsscache( new cache(dbfile.getPath(), &cfg) );
rss_parser parser("file://data/rss.xml", rsscache.get(), &cfg, nullptr);
std::shared_ptr<rss_feed> feed = parser.parse();
rsscache->externalize_rssfeed(feed, false);

REQUIRE_NOTHROW(rsscache->do_vacuum());

// Checking that cache can still be opened
REQUIRE_NOTHROW(rsscache.reset( new cache(dbfile.getPath(), &cfg) ));
}

0 comments on commit bf4e1b8

Please sign in to comment.