sagiegurari / cargo-make
1
use super::*;
2
use crate::test;
3

4
#[test]
5
#[cfg(target_os = "linux")]
6 8
fn get_legacy_cargo_make_home_linux() {
7 8
    let mut home = envmnt::get_or_panic("HOME");
8 8
    home.push_str("/.cargo-make");
9 8
    let cargo_make_home = get_legacy_cargo_make_home().unwrap();
10

11 8
    assert_eq!(home, cargo_make_home.to_str().unwrap());
12 8
}
13

14
#[test]
15
#[ignore]
16 2
fn get_cargo_make_home_no_env() {
17 2
    envmnt::remove("CARGO_MAKE_HOME");
18

19 2
    let cargo_make_home = get_legacy_cargo_make_home().unwrap();
20 2
    let home = get_cargo_make_home().unwrap();
21 2
    assert_eq!(home, cargo_make_home);
22 2
}
23

24
#[test]
25
#[ignore]
26 2
fn get_cargo_make_home_with_env() {
27 2
    let path = env::current_dir().unwrap();
28 2
    let directory = path.join("examples/cargo-make");
29 2
    envmnt::set("CARGO_MAKE_HOME", directory.to_str().unwrap());
30

31 2
    let home = get_cargo_make_home().unwrap();
32

33 2
    envmnt::remove("CARGO_MAKE_HOME");
34

35 2
    assert_eq!(home, directory);
36 2
}
37

38
#[test]
39
#[ignore]
40 2
fn migrate_from_directory_not_exists() {
41 2
    let path = env::current_dir().unwrap();
42 2
    let legacy_directory = path.join("legacy_bad");
43 2
    let target_directory = path.join("target_bad");
44

45 2
    let done = migrate_from_directory(target_directory, "test.txt", &legacy_directory);
46

47 2
    assert!(done);
48 2
}
49

50
#[test]
51
#[ignore]
52 2
fn migrate_from_directory_dir_exists_file_not_exists() {
53 2
    let path = env::current_dir().unwrap();
54 2
    let target_directory = path.join("target_bad");
55

56 2
    let legacy_directory = test::get_temp_test_directory();
57

58 2
    let done = migrate_from_directory(target_directory, "test.txt", &legacy_directory);
59

60 2
    assert!(done);
61 2
}
62

63
#[test]
64
#[ignore]
65 2
fn migrate_from_directory_delete_legacy_directory() {
66 2
    let test_directory = test::get_temp_test_directory();
67 2
    let legacy_directory = test_directory.join("legacy");
68 2
    let target_directory = test_directory.join("target");
69

70 2
    let legacy_file = legacy_directory.join("test.txt");
71 2
    fsio::file::write_text_file(&legacy_file, "test 123").unwrap();
72

73 2
    let done = migrate_from_directory(target_directory.clone(), "test.txt", &legacy_directory);
74

75 2
    assert!(done);
76

77 2
    assert!(target_directory.exists());
78

79
    #[cfg(target_os = "linux")]
80 2
    assert!(!legacy_directory.exists());
81

82 2
    let target_file = target_directory.join("test.txt");
83 2
    let file_text = fsio::file::read_text_file(&target_file).unwrap();
84

85 2
    assert_eq!(&file_text, "test 123");
86 2
}
87

88
#[test]
89 8
fn show_deprecated_attriute_warning_valid() {
90 8
    show_deprecated_attriute_warning("old", "new");
91 8
}

Read our documentation on viewing source code .

Loading