mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Tests: Move test apparent size to exact_output
Because apparent_size uses the test files created in /tmp it needs to be in the test_exact_output where those files are copied. Otherwise the files may not be there when the test is run.
This commit is contained in:
@@ -192,3 +192,22 @@ fn unicode_dir() -> Vec<String> {
|
||||
.into();
|
||||
vec![mac_and_some_linux, ubuntu]
|
||||
}
|
||||
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_apparent_size() {
|
||||
let command_args = vec!["-c", "-s", "-b", "/tmp/test_dir"];
|
||||
exact_output_test(apparent_size_output(), command_args);
|
||||
}
|
||||
|
||||
fn apparent_size_output() -> Vec<String> {
|
||||
// The apparent directory sizes are too unpredictable and system dependant to try and match
|
||||
let files = r#"
|
||||
0B ┌── a_file
|
||||
6B ├── hello_file
|
||||
"#
|
||||
.trim()
|
||||
.to_string();
|
||||
|
||||
vec![files]
|
||||
}
|
||||
|
||||
+22
-18
@@ -101,22 +101,6 @@ pub fn test_number_of_files() {
|
||||
assert!(output.contains("2 ┌─┴ test_dir"));
|
||||
}
|
||||
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_apparent_size() {
|
||||
// Check the '-s' Flag gives us byte sizes and that it doesn't round up to a block
|
||||
let command_args = vec!["-c", "-s", "/tmp/test_dir"];
|
||||
let output = build_command(command_args);
|
||||
|
||||
let apparent_size1 = "6B ├── hello_file│";
|
||||
let apparent_size2 = "0B ┌── a_file";
|
||||
assert!(output.contains(apparent_size1));
|
||||
assert!(output.contains(apparent_size2));
|
||||
|
||||
let incorrect_apparent_size = "4.0K ├── hello_file";
|
||||
assert!(!output.contains(incorrect_apparent_size));
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_show_files_by_type() {
|
||||
// Check we can list files by type
|
||||
@@ -144,9 +128,20 @@ pub fn test_show_files_by_regex_match_nothing() {
|
||||
assert!(output.contains("0B ┌── tests"));
|
||||
}
|
||||
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[cfg_attr(target_os = "macos", ignore)] // TODO: Figure out why mac doesnt like this test
|
||||
#[test]
|
||||
pub fn test_show_files_by_regex_match_multiple() {
|
||||
let output = build_command(vec!["-c", "-e", "test_dir2", "-e", "unicode", "tests"]);
|
||||
let output = build_command(vec![
|
||||
"-c",
|
||||
"-e",
|
||||
"test_dir_unicode",
|
||||
"-e",
|
||||
"test_dir2",
|
||||
"-n",
|
||||
"100",
|
||||
"tests",
|
||||
]);
|
||||
assert!(output.contains("test_dir2"));
|
||||
assert!(output.contains("test_dir_unicode"));
|
||||
assert!(!output.contains("many")); // We do not find the 'many' folder in the 'test_dir' folder
|
||||
@@ -171,7 +166,16 @@ pub fn test_show_files_by_invert_regex() {
|
||||
pub fn test_show_files_by_invert_regex_match_multiple() {
|
||||
// We ignore test_dir2 & test_dir_unicode, leaving the test_dir folder
|
||||
// which has the 'many' folder inside
|
||||
let output = build_command(vec!["-c", "-v", "test_dir2", "-v", "unicode", "tests"]);
|
||||
let output = build_command(vec![
|
||||
"-c",
|
||||
"-v",
|
||||
"test_dir2",
|
||||
"-v",
|
||||
"test_dir_unicode",
|
||||
"-n",
|
||||
"100",
|
||||
"tests",
|
||||
]);
|
||||
assert!(!output.contains("test_dir2"));
|
||||
assert!(!output.contains("test_dir_unicode"));
|
||||
assert!(output.contains("many"));
|
||||
|
||||
Reference in New Issue
Block a user