summaryrefslogtreecommitdiff
path: root/rust/libnewsboat/tests/configpaths_12.rs
blob: 915f8f8076ec32ff8fab0583fd4a091acc991fa1 (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
use std::env;
use tempfile::TempDir;

mod configpaths_helpers;
use crate::configpaths_helpers::libc::{S_IRUSR, S_IXUSR};

#[test]
fn t_configpaths_try_migrate_from_newsbeuter_does_not_migrate_if_newsboat_dotdir_couldnt_be_created(
) {
    let tmp = TempDir::new().unwrap();

    env::set_var("HOME", tmp.path());

    // ConfigPaths rely on these variables, so let's sanitize them to ensure
    // that the tests aren't affected
    env::remove_var("XDG_CONFIG_HOME");
    env::remove_var("XDG_DATA_HOME");

    configpaths_helpers::mock_newsbeuter_dotdir(&tmp);

    // Making home directory unwriteable makes it impossible to create
    // a directory there
    let _dotdir_chmod = configpaths_helpers::Chmod::new(tmp.path(), S_IRUSR | S_IXUSR);

    configpaths_helpers::assert_dotdir_not_migrated(&tmp.path().join(".newsboat"));
}