sagiegurari / cargo-make
1
use super::*;
2
use envmnt;
3
use std::env;
4
use std::path::PathBuf;
5

6
#[test]
7 8
fn load_from_path_exists() {
8 8
    let path = PathBuf::from("examples/cargo-make");
9 8
    let global_config = load_from_path(path);
10

11 8
    assert!(global_config.file_name.is_some());
12 8
    assert_eq!(global_config.log_level.unwrap(), "error".to_string());
13 2
    assert_eq!(
14 8
        global_config.default_task_name.unwrap(),
15 8
        "build".to_string()
16
    );
17 2
    assert_eq!(
18 8
        global_config.update_check_minimum_interval.unwrap(),
19 8
        "daily".to_string()
20
    );
21 8
    assert!(global_config.search_project_root.unwrap());
22 8
}
23

24
#[test]
25 8
fn load_from_path_not_exists() {
26 8
    let path = PathBuf::from("examples2/.cargo-make");
27 8
    let global_config = load_from_path(path);
28

29 8
    assert!(global_config.file_name.is_none());
30 8
    assert!(global_config.log_level.is_none());
31 8
    assert!(global_config.default_task_name.is_none());
32 8
    assert!(global_config.update_check_minimum_interval.is_none());
33 8
    assert!(!global_config.search_project_root.unwrap());
34 8
}
35

36
#[test]
37
#[ignore]
38 2
fn load_with_cargo_home() {
39 2
    let path = env::current_dir().unwrap();
40 2
    let directory = path.join("examples/cargo-make");
41 2
    envmnt::set("CARGO_MAKE_HOME", directory.to_str().unwrap());
42 2
    let global_config = load();
43

44 2
    assert!(global_config.file_name.is_some());
45 2
    assert_eq!(global_config.log_level.unwrap(), "error".to_string());
46 2
    assert_eq!(
47 2
        global_config.default_task_name.unwrap(),
48 2
        "build".to_string()
49
    );
50 2
    assert_eq!(
51 2
        global_config.update_check_minimum_interval.unwrap(),
52 2
        "daily".to_string()
53
    );
54 2
    assert!(global_config.search_project_root.unwrap());
55 2
}
56

57
#[test]
58
#[ignore]
59 2
fn load_without_cargo_home() {
60 2
    envmnt::remove("CARGO_MAKE_HOME");
61 2
    let global_config = load();
62

63 2
    assert!(global_config.search_project_root.is_some());
64 2
}

Read our documentation on viewing source code .

Loading