blob: c1a9785ef00e5b47527b47fb699160278f6523c6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#define ENABLE_IMPLICIT_FILEPATH_CONVERSIONS
#include "controller.h"
#include <string>
#include <unistd.h>
#include "configpaths.h"
#include "cache.h"
#include "utils.h"
#include "rssitem.h"
#include "3rd-party/catch.hpp"
#include "test_helpers/tempdir.h"
#include "test_helpers/envvar.h"
#include "test_helpers/misc.h"
using namespace newsboat;
TEST_CASE("write_item correctly parses path", "[Controller]")
{
std::string name = "myitem";
test_helpers::TempDir tmp;
const auto home_dir = tmp.get_path().join("home");
REQUIRE(0 == utils::mkdir_parents(home_dir, 0700));
const auto save_path = tmp.get_path().join("save");
REQUIRE(0 == utils::mkdir_parents(save_path, 0700));
test_helpers::EnvVar home("HOME");
home.set(home_dir);
ConfigPaths paths{};
Controller c(paths);
auto cfg = c.get_config();
cfg->set_configvalue("save-path", save_path);
Cache rsscache(":memory:", *cfg);
RssItem item(&rsscache);
item.set_title("title");
const auto description = "First line.\nSecond one.\nAnd finally the third";
item.set_description(description, "text/plain");
c.write_item(item, tmp.get_path().join(name));
c.write_item(item, "~/" + name);
c.write_item(item, name);
REQUIRE(test_helpers::file_available_for_reading(tmp.get_path().join(name)));
REQUIRE(test_helpers::file_available_for_reading(home_dir.join(name)));
REQUIRE(test_helpers::file_available_for_reading(save_path.join(name)));
}
|