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

5
#[test]
6 8
fn is_installed_true() {
7 8
    let output = is_installed(&None, "cargo", &["--version".to_string()]);
8 8
    assert!(output);
9 8
}
10

11
#[test]
12 8
fn is_installed_false() {
13 8
    let output = is_installed(&None, "cargo_bad", &["--version".to_string()]);
14 8
    assert!(!output);
15 8
}
16

17
#[test]
18 8
fn is_installed_non_zero() {
19 8
    let output = is_installed(&None, "exit", &["1".to_string()]);
20 8
    assert!(!output);
21 8
}
22

23
#[test]
24 8
fn is_installed_with_toolchain_true() {
25 8
    if test::is_not_rust_stable() {
26 4
        let toolchain = test::get_toolchain();
27

28 4
        let output = is_installed(&Some(toolchain), "cargo", &["--version".to_string()]);
29 4
        assert!(output);
30
    }
31 8
}
32

33
#[test]
34 8
fn is_installed_with_toolchain_false() {
35 8
    if test::is_not_rust_stable() {
36 4
        let toolchain = test::get_toolchain();
37

38 4
        let output = is_installed(&Some(toolchain), "cargo_bad", &["--version".to_string()]);
39 4
        assert!(!output);
40
    }
41 8
}
42

43
#[test]
44 8
fn is_installed_with_toolchain_non_zero() {
45 8
    let toolchain = test::get_toolchain();
46

47 8
    let output = is_installed(&Some(toolchain), "exit", &["1".to_string()]);
48 8
    assert!(!output);
49 8
}
50

51
#[test]
52 8
fn invoke_rustup_install_fail() {
53 8
    let info = InstallRustupComponentInfo {
54 8
        rustup_component_name: "unknown_rustup_component_test".to_string(),
55 8
        binary: Some("cargo_bad".to_string()),
56 8
        test_arg: Some(TestArg {
57 8
            inner: vec!["--help".to_string()],
58
        }),
59 0
    };
60

61 8
    let output = invoke_rustup_install(&None, &info);
62 8
    assert!(!output);
63 8
}
64

65
#[test]
66 8
fn invoke_rustup_install_with_toolchain_fail() {
67 8
    let toolchain = test::get_toolchain();
68

69 8
    let info = InstallRustupComponentInfo {
70 8
        rustup_component_name: "unknown_rustup_component_test".to_string(),
71 8
        binary: Some("cargo_bad".to_string()),
72 8
        test_arg: Some(TestArg {
73 8
            inner: vec!["--help".to_string()],
74
        }),
75 0
    };
76

77 8
    let output = invoke_rustup_install(&Some(toolchain), &info);
78 8
    assert!(!output);
79 8
}
80

81
#[test]
82 8
fn install_test() {
83 8
    let info = InstallRustupComponentInfo {
84 8
        rustup_component_name: "unknown_rustup_component_test".to_string(),
85 8
        binary: Some("cargo_bad".to_string()),
86 8
        test_arg: Some(TestArg {
87 8
            inner: vec!["--help".to_string()],
88
        }),
89 0
    };
90

91 8
    let output = install(&None, &info, false);
92 8
    assert!(!output);
93 8
}
94

95
#[test]
96 8
fn install_with_toolchain_test() {
97 8
    let toolchain = test::get_toolchain();
98

99 8
    let info = InstallRustupComponentInfo {
100 8
        rustup_component_name: "unknown_rustup_component_test".to_string(),
101 8
        binary: Some("cargo_bad".to_string()),
102 8
        test_arg: Some(TestArg {
103 8
            inner: vec!["--help".to_string()],
104
        }),
105 0
    };
106

107 8
    let output = install(&Some(toolchain), &info, false);
108 8
    assert!(!output);
109 8
}

Read our documentation on viewing source code .

Loading