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

3
#[test]
4 8
fn get_level_verbose() {
5 8
    let level = get_level("verbose");
6 8
    assert_eq!(level, LogLevel::VERBOSE);
7 8
}
8

9
#[test]
10 8
fn get_level_info() {
11 8
    let level = get_level("info");
12 8
    assert_eq!(level, LogLevel::INFO);
13 8
}
14

15
#[test]
16 8
fn get_level_error() {
17 8
    let level = get_level("error");
18 8
    assert_eq!(level, LogLevel::ERROR);
19 8
}
20

21
#[test]
22 8
fn get_level_other() {
23 8
    let level = get_level("test123");
24 8
    assert_eq!(level, LogLevel::INFO);
25 8
}
26

27
#[test]
28 8
fn get_name_for_level_verbose() {
29 8
    let level = get_name_for_level(&Level::Debug);
30 8
    assert_eq!(level, "verbose");
31 8
}
32

33
#[test]
34 8
fn get_name_for_level_info() {
35 8
    let level = get_name_for_level(&Level::Info);
36 8
    assert_eq!(level, "info");
37 8
}
38

39
#[test]
40 8
fn get_name_for_level_error() {
41 8
    let level = get_name_for_level(&Level::Error);
42 8
    assert_eq!(level, "error");
43 8
}
44

45
#[test]
46 8
fn get_name_for_level_warn() {
47 8
    let level = get_name_for_level(&Level::Warn);
48 8
    assert_eq!(level, "warn");
49 8
}
50

51
#[test]
52 8
fn get_name_for_level_other() {
53 8
    let level = get_name_for_level(&Level::Trace);
54 8
    assert_eq!(level, "info");
55 8
}
56

57
#[test]
58 8
fn get_name_for_filter_verbose() {
59 8
    let level = get_name_for_filter(&LevelFilter::Debug);
60 8
    assert_eq!(level, "verbose");
61 8
}
62

63
#[test]
64 8
fn get_name_for_filter_info() {
65 8
    let level = get_name_for_filter(&LevelFilter::Info);
66 8
    assert_eq!(level, "info");
67 8
}
68

69
#[test]
70 8
fn get_name_for_filter_error() {
71 8
    let level = get_name_for_filter(&LevelFilter::Error);
72 8
    assert_eq!(level, "error");
73 8
}
74

75
#[test]
76 8
fn get_name_for_filter_warn() {
77 8
    let level = get_name_for_filter(&LevelFilter::Warn);
78 8
    assert_eq!(level, "warn");
79 8
}
80

81
#[test]
82 8
fn get_name_for_filter_other() {
83 8
    let level = get_name_for_filter(&LevelFilter::Trace);
84 8
    assert_eq!(level, "info");
85 8
}
86

87
#[test]
88 8
fn get_formatted_name_with_color() {
89 8
    let output = get_formatted_name("test", true);
90

91 8
    assert_eq!("test".bold(), output);
92 8
}
93

94
#[test]
95 8
fn get_formatted_name_no_color() {
96 8
    let output = get_formatted_name("test", false);
97

98 8
    assert_eq!("test".normal(), output);
99 8
}
100

101
#[test]
102 8
fn get_formatted_log_level_debug_with_color() {
103 8
    let output = get_formatted_log_level(&Level::Debug, true);
104

105 8
    assert_eq!("VERBOSE".cyan().bold(), output);
106 8
}
107

108
#[test]
109 8
fn get_formatted_log_level_info_with_color() {
110 8
    let output = get_formatted_log_level(&Level::Info, true);
111

112 8
    assert_eq!("INFO".green().bold(), output);
113 8
}
114

115
#[test]
116 8
fn get_formatted_log_level_warn_with_color() {
117 8
    let output = get_formatted_log_level(&Level::Warn, true);
118

119 8
    assert_eq!("WARN".yellow().bold(), output);
120 8
}
121

122
#[test]
123 8
fn get_formatted_log_level_error_with_color() {
124 8
    let output = get_formatted_log_level(&Level::Error, true);
125

126 8
    assert_eq!("ERROR".red().bold(), output);
127 8
}
128

129
#[test]
130 8
fn get_formatted_log_level_debug_no_color() {
131 8
    let output = get_formatted_log_level(&Level::Debug, false);
132

133 8
    assert_eq!("VERBOSE".normal(), output);
134 8
}
135

136
#[test]
137 8
fn get_formatted_log_level_info_no_color() {
138 8
    let output = get_formatted_log_level(&Level::Info, false);
139

140 8
    assert_eq!("INFO".normal(), output);
141 8
}
142

143
#[test]
144 8
fn get_formatted_log_level_warn_no_color() {
145 8
    let output = get_formatted_log_level(&Level::Warn, false);
146

147 8
    assert_eq!("WARN".normal(), output);
148 8
}
149

150
#[test]
151 8
fn get_formatted_log_level_error_no_color() {
152 8
    let output = get_formatted_log_level(&Level::Error, false);
153

154 8
    assert_eq!("ERROR".normal(), output);
155 8
}
156

157
#[test]
158
#[should_panic]
159 8
fn create_error() {
160 8
    init(&LoggerOptions {
161 8
        level: "error".to_string(),
162
        color: false,
163 2
    });
164

165 8
    error!("test");
166 0
}
167

168
#[test]
169
#[ignore]
170 2
fn update_disable_color_env_var() {
171 2
    envmnt::remove("CARGO_MAKE_DISABLE_COLOR");
172

173 2
    init(&LoggerOptions {
174 2
        level: "info".to_string(),
175
        color: false,
176 2
    });
177

178 2
    assert!(envmnt::is("CARGO_MAKE_DISABLE_COLOR"));
179 2
}

Read our documentation on viewing source code .

Loading