aboutsummaryrefslogtreecommitdiff
path: root/test/queuemanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/queuemanager.cpp')
-rw-r--r--test/queuemanager.cpp96
1 files changed, 48 insertions, 48 deletions
diff --git a/test/queuemanager.cpp b/test/queuemanager.cpp
index 5baffb0c..83a02f5d 100644
--- a/test/queuemanager.cpp
+++ b/test/queuemanager.cpp
@@ -20,14 +20,14 @@ SCENARIO("Smoke test for QueueManager", "[QueueManager]")
GIVEN("A fresh instance of QueueManager") {
ConfigContainer cfg;
- Cache cache(":memory:", cfg);
+ auto rsscache = Cache::in_memory(cfg);
- RssItem item(&cache);
+ RssItem item(rsscache.get());
const std::string enclosure_url("https://example.com/podcast.mp3");
item.set_enclosure_url(enclosure_url);
item.set_enclosure_type("audio/mpeg");
- RssFeed feed(&cache, "https://example.com/news.atom");
+ RssFeed feed(rsscache.get(), "https://example.com/news.atom");
test_helpers::TempFile queue_file;
QueueManager manager(&cfg, queue_file.get_path());
@@ -88,12 +88,12 @@ SCENARIO("Smoke test for QueueManager", "[QueueManager]")
WHEN("enqueue_url() is called for multiple different items") {
const auto result = manager.enqueue_url(item, feed);
- RssItem item2(&cache);
+ RssItem item2(rsscache.get());
item2.set_enclosure_url("https://www.example.com/another.mp3");
item2.set_enclosure_type("audio/mpeg");
const auto result2 = manager.enqueue_url(item2, feed);
- RssItem item3(&cache);
+ RssItem item3(rsscache.get());
item3.set_enclosure_url("https://joe.example.com/vacation.jpg");
item3.set_enclosure_type("image/jpeg");
const auto result3 = manager.enqueue_url(item3, feed);
@@ -134,19 +134,19 @@ SCENARIO("enqueue_url() errors if the filename is already used", "[QueueManager]
GIVEN("Pristine QueueManager and two RssItems") {
ConfigContainer cfg;
- Cache cache(":memory:", cfg);
+ auto rsscache = Cache::in_memory(cfg);
- RssItem item1(&cache);
+ RssItem item1(rsscache.get());
const std::string enclosure_url1("https://example.com/podcast.mp3");
item1.set_enclosure_url(enclosure_url1);
item1.set_enclosure_type("audio/mpeg");
- RssItem item2(&cache);
+ RssItem item2(rsscache.get());
const std::string enclosure_url2("https://example.com/~joe/podcast.mp3");
item2.set_enclosure_url(enclosure_url2);
item2.set_enclosure_type("audio/mpeg");
- RssFeed feed(&cache, "https://example.com/news.atom");
+ RssFeed feed(rsscache.get(), "https://example.com/news.atom");
test_helpers::TempFile queue_file;
QueueManager manager(&cfg, queue_file.get_path());
@@ -210,13 +210,13 @@ SCENARIO("enqueue_url() errors if the queue file can't be opened for writing",
GIVEN("Pristine QueueManager, an RssItem, and an uneditable queue file") {
ConfigContainer cfg;
- Cache cache(":memory:", cfg);
+ auto rsscache = Cache::in_memory(cfg);
- RssItem item(&cache);
+ RssItem item(rsscache.get());
item.set_enclosure_url("https://example.com/podcast.mp3");
item.set_enclosure_type("audio/mpeg");
- RssFeed feed(&cache, "https://example.com/news.atom");
+ RssFeed feed(rsscache.get(), "https://example.com/news.atom");
test_helpers::TempFile queue_file;
QueueManager manager(&cfg, queue_file.get_path());
@@ -251,19 +251,19 @@ TEST_CASE("QueueManager puts files into a location configured by `download-path`
cfg.set_configvalue("download-path", "/tmp/nonexistent-newsboat");
}
- Cache cache(":memory:", cfg);
+ auto rsscache = Cache::in_memory(cfg);
- RssItem item1(&cache);
+ RssItem item1(rsscache.get());
const std::string enclosure_url1("https://example.com/podcast.mp3");
item1.set_enclosure_url(enclosure_url1);
item1.set_enclosure_type("audio/mpeg");
- RssItem item2(&cache);
+ RssItem item2(rsscache.get());
const std::string enclosure_url2("https://example.com/~joe/podcast.ogg");
item2.set_enclosure_url(enclosure_url2);
item2.set_enclosure_type("audio/vorbis");
- RssFeed feed(&cache, "https://example.com/podcasts.atom");
+ RssFeed feed(rsscache.get(), "https://example.com/podcasts.atom");
test_helpers::TempFile queue_file;
QueueManager manager(&cfg, queue_file.get_path());
@@ -299,13 +299,13 @@ TEST_CASE("QueueManager names files according to the `download-filename-format`
// *exactly* how the result should look.
cfg.set_configvalue("download-path", "/example/");
- Cache cache(":memory:", cfg);
+ auto rsscache = Cache::in_memory(cfg);
- RssItem item(&cache);
+ RssItem item(rsscache.get());
item.set_enclosure_url("https://example.com/~adam/podcast.mp3");
item.set_enclosure_type("audio/mpeg");
- auto feed = std::make_shared<RssFeed>(&cache, "https://example.com/podcasts.atom");
+ auto feed = std::make_shared<RssFeed>(rsscache.get(), "https://example.com/podcasts.atom");
test_helpers::TempFile queue_file;
QueueManager manager(&cfg, queue_file.get_path());
@@ -396,7 +396,7 @@ TEST_CASE("QueueManager names files according to the `download-filename-format`
item.set_feedptr(feed);
- RssFeed irrelevant_feed(&cache, "https://example.com/podcasts.atom");
+ RssFeed irrelevant_feed(rsscache.get(), "https://example.com/podcasts.atom");
irrelevant_feed.set_title("Irrelevant");
manager.enqueue_url(item, irrelevant_feed);
@@ -428,21 +428,21 @@ TEST_CASE("autoenqueue() adds all enclosures of all items to the queue", "[Queue
GIVEN("Pristine QueueManager and a feed of three items") {
ConfigContainer cfg;
- Cache cache(":memory:", cfg);
+ auto rsscache = Cache::in_memory(cfg);
- RssFeed feed(&cache, "https://example.com/podcasts.atom");
+ RssFeed feed(rsscache.get(), "https://example.com/podcasts.atom");
- auto item1 = std::make_shared<RssItem>(&cache);
+ auto item1 = std::make_shared<RssItem>(rsscache.get());
item1->set_enclosure_url("https://example.com/~adam/podcast.mp3");
item1->set_enclosure_type("audio/mpeg");
feed.add_item(item1);
- auto item2 = std::make_shared<RssItem>(&cache);
+ auto item2 = std::make_shared<RssItem>(rsscache.get());
item2->set_enclosure_url("https://example.com/episode.ogg");
item2->set_enclosure_type("audio/vorbis");
feed.add_item(item2);
- auto item3 = std::make_shared<RssItem>(&cache);
+ auto item3 = std::make_shared<RssItem>(rsscache.get());
item3->set_enclosure_url("https://example.com/~fae/painting.jpg");
item3->set_enclosure_type("");
feed.add_item(item3);
@@ -483,17 +483,17 @@ SCENARIO("autoenqueue() errors if the filename is already used", "[QueueManager]
GIVEN("Pristine QueueManager and a feed of two items") {
ConfigContainer cfg;
- Cache cache(":memory:", cfg);
+ auto rsscache = Cache::in_memory(cfg);
- RssFeed feed(&cache, "https://example.com/news.atom");
+ RssFeed feed(rsscache.get(), "https://example.com/news.atom");
- auto item1 = std::make_shared<RssItem>(&cache);
+ auto item1 = std::make_shared<RssItem>(rsscache.get());
const std::string enclosure_url1("https://example.com/podcast.mp3");
item1->set_enclosure_url(enclosure_url1);
item1->set_enclosure_type("audio/mpeg");
feed.add_item(item1);
- auto item2 = std::make_shared<RssItem>(&cache);
+ auto item2 = std::make_shared<RssItem>(rsscache.get());
const std::string enclosure_url2("https://example.com/~joe/podcast.mp3");
item2->set_enclosure_url(enclosure_url2);
item2->set_enclosure_type("audio/mpeg");
@@ -537,11 +537,11 @@ SCENARIO("autoenqueue() errors if the queue file can't be opened for writing",
GIVEN("Pristine QueueManager, a single-item feed, and an uneditable queue file") {
ConfigContainer cfg;
- Cache cache(":memory:", cfg);
+ auto rsscache = Cache::in_memory(cfg);
- RssFeed feed(&cache, "https://example.com/news.atom");
+ RssFeed feed(rsscache.get(), "https://example.com/news.atom");
- auto item = std::make_shared<RssItem>(&cache);
+ auto item = std::make_shared<RssItem>(rsscache.get());
item->set_enclosure_url("https://example.com/podcast.mp3");
item->set_enclosure_type("audio/mpeg");
feed.add_item(item);
@@ -575,22 +575,22 @@ TEST_CASE("autoenqueue() skips already-enqueued items", "[QueueManager]")
// *exactly* how the result should look.
cfg.set_configvalue("download-path", "/example/");
- Cache cache(":memory:", cfg);
+ auto rsscache = Cache::in_memory(cfg);
- RssFeed feed(&cache, "https://example.com/news.atom");
+ RssFeed feed(rsscache.get(), "https://example.com/news.atom");
- auto item1 = std::make_shared<RssItem>(&cache);
+ auto item1 = std::make_shared<RssItem>(rsscache.get());
item1->set_enclosure_url("https://example.com/podcast.mp3");
item1->set_enclosure_type("audio/mpeg");
feed.add_item(item1);
- auto item2 = std::make_shared<RssItem>(&cache);
+ auto item2 = std::make_shared<RssItem>(rsscache.get());
item2->set_enclosure_url("https://example.com/podcast2.mp3");
item2->set_enclosure_type("audio/mpeg");
item2->set_enqueued(true);
feed.add_item(item2);
- auto item3 = std::make_shared<RssItem>(&cache);
+ auto item3 = std::make_shared<RssItem>(rsscache.get());
item3->set_enclosure_url("https://example.com/podcast3.mp3");
item3->set_enclosure_type("audio/mpeg");
feed.add_item(item3);
@@ -618,21 +618,21 @@ TEST_CASE("autoenqueue() only enqueues HTTP and HTTPS URLs", "[QueueManager]")
// *exactly* how the result should look.
cfg.set_configvalue("download-path", "/example/");
- Cache cache(":memory:", cfg);
+ auto rsscache = Cache::in_memory(cfg);
- RssFeed feed(&cache, "https://example.com/news.atom");
+ RssFeed feed(rsscache.get(), "https://example.com/news.atom");
- auto item1 = std::make_shared<RssItem>(&cache);
+ auto item1 = std::make_shared<RssItem>(rsscache.get());
item1->set_enclosure_url("https://example.com/podcast.mp3");
item1->set_enclosure_type("audio/mpeg");
feed.add_item(item1);
- auto item2 = std::make_shared<RssItem>(&cache);
+ auto item2 = std::make_shared<RssItem>(rsscache.get());
item2->set_enclosure_url("http://example.com/podcast2.mp3");
item2->set_enclosure_type("audio/mpeg");
feed.add_item(item2);
- auto item3 = std::make_shared<RssItem>(&cache);
+ auto item3 = std::make_shared<RssItem>(rsscache.get());
item3->set_enclosure_url("ftp://user@example.com/podcast3.mp3");
item3->set_enclosure_type("audio/mpeg");
feed.add_item(item3);
@@ -658,26 +658,26 @@ TEST_CASE("autoenqueue() does not enqueue items with an invalid podcast type",
{
GIVEN("Pristine QueueManager and a feed of three items with one of them having an image enclosure") {
ConfigContainer cfg;
- Cache cache(":memory:", cfg);
+ auto rsscache = Cache::in_memory(cfg);
- RssFeed feed(&cache, "https://example.com/news.atom");
+ RssFeed feed(rsscache.get(), "https://example.com/news.atom");
- auto item1 = std::make_shared<RssItem>(&cache);
+ auto item1 = std::make_shared<RssItem>(rsscache.get());
item1->set_enclosure_url("https://example.com/podcast1.mp3");
item1->set_enclosure_type("audio/mpeg");
feed.add_item(item1);
- auto item2 = std::make_shared<RssItem>(&cache);
+ auto item2 = std::make_shared<RssItem>(rsscache.get());
item2->set_enclosure_url("http://example.com/not-a-podcast.jpg");
item2->set_enclosure_type("image/jpeg");
feed.add_item(item2);
- auto item3 = std::make_shared<RssItem>(&cache);
+ auto item3 = std::make_shared<RssItem>(rsscache.get());
item3->set_enclosure_url("https://example.com/podcast2.mp3");
item3->set_enclosure_type("audio/mpeg");
feed.add_item(item3);
- auto item4 = std::make_shared<RssItem>(&cache);
+ auto item4 = std::make_shared<RssItem>(rsscache.get());
item4->set_enclosure_url("https://example.com/podcast3.mp3");
item4->set_enclosure_type("");
feed.add_item(item4);