diff options
author | Dan Davison <dandavison7@gmail.com> | 2020-06-10 17:22:02 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2020-06-10 17:26:44 -0400 |
commit | 5d90f26d68f5d92e29c03194258e9052d6b8a732 (patch) | |
tree | c644d472b97edb84437fb5f620e336d54635ce88 /src/tests | |
parent | 2b8869cf16dd15469753849fae2fb3c26e82bbcf (diff) |
Refactor tests
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/integration_test_utils.rs | 6 | ||||
-rw-r--r-- | src/tests/test_example_diffs.rs | 220 |
2 files changed, 88 insertions, 138 deletions
diff --git a/src/tests/integration_test_utils.rs b/src/tests/integration_test_utils.rs index 5d9be02b..cfbd8877 100644 --- a/src/tests/integration_test_utils.rs +++ b/src/tests/integration_test_utils.rs @@ -10,7 +10,7 @@ pub mod integration_test_utils { use crate::config; use crate::delta::delta; - pub fn get_config_from_args<'a>(_args: &[&str]) -> config::Config<'a> { + pub fn make_config<'a>(_args: &[&str]) -> config::Config<'a> { // FIXME: should not be necessary let (dummy_minus_file, dummy_plus_file) = ("/dev/null", "/dev/null"); let mut args = vec![dummy_minus_file, dummy_plus_file]; @@ -23,10 +23,6 @@ pub mod integration_test_utils { cli::process_command_line_arguments(arg_matches, &mut None) } - pub fn get_config<'a>() -> config::Config<'a> { - get_config_from_args(&vec![][0..]) - } - pub fn get_line_of_code_from_delta<'a>( input: &str, line_number: usize, diff --git a/src/tests/test_example_diffs.rs b/src/tests/test_example_diffs.rs index a64bc76b..3cfb1435 100644 --- a/src/tests/test_example_diffs.rs +++ b/src/tests/test_example_diffs.rs @@ -2,13 +2,12 @@ mod tests { use console::strip_ansi_codes; - use crate::config; use crate::tests::ansi_test_utils::ansi_test_utils; use crate::tests::integration_test_utils::integration_test_utils; #[test] fn test_added_file() { - let config = integration_test_utils::get_config(); + let config = integration_test_utils::make_config(&[]); let output = integration_test_utils::run_delta(ADDED_FILE_INPUT, &config); let output = strip_ansi_codes(&output); assert!(output.contains("\nadded: a.py\n")); @@ -21,7 +20,7 @@ mod tests { #[test] #[ignore] // #128 fn test_added_empty_file() { - let config = integration_test_utils::get_config(); + let config = integration_test_utils::make_config(&[]); let output = integration_test_utils::run_delta(ADDED_EMPTY_FILE, &config); let output = strip_ansi_codes(&output); assert!(output.contains("\nadded: file\n")); @@ -29,7 +28,7 @@ mod tests { #[test] fn test_added_file_directory_path_containing_space() { - let config = integration_test_utils::get_config(); + let config = integration_test_utils::make_config(&[]); let output = integration_test_utils::run_delta(ADDED_FILES_DIRECTORY_PATH_CONTAINING_SPACE, &config); let output = strip_ansi_codes(&output); @@ -39,7 +38,7 @@ mod tests { #[test] fn test_renamed_file() { - let config = integration_test_utils::get_config(); + let config = integration_test_utils::make_config(&[]); let output = integration_test_utils::run_delta(RENAMED_FILE_INPUT, &config); let output = strip_ansi_codes(&output); assert!(output.contains("\nrenamed: a.py ⟶ b.py\n")); @@ -48,7 +47,7 @@ mod tests { #[test] fn test_recognized_file_type() { // In addition to the background color, the code has language syntax highlighting. - let config = integration_test_utils::get_config(); + let config = integration_test_utils::make_config(&[]); let output = integration_test_utils::get_line_of_code_from_delta( &ADDED_FILE_INPUT, 12, @@ -62,7 +61,7 @@ mod tests { fn test_unrecognized_file_type_with_syntax_theme() { // In addition to the background color, the code has the foreground color using the default // .txt syntax under the theme. - let config = integration_test_utils::get_config(); + let config = integration_test_utils::make_config(&[]); let input = ADDED_FILE_INPUT.replace("a.py", "a"); let output = integration_test_utils::get_line_of_code_from_delta(&input, 12, " class X:", &config); @@ -73,12 +72,8 @@ mod tests { fn test_unrecognized_file_type_no_syntax_theme() { // The code has the background color only. (Since there is no theme, the code has no // foreground ansi color codes.) - let config = integration_test_utils::get_config_from_args(&[ - "--syntax-theme", - "none", - "--width", - "variable", - ]); + let config = + integration_test_utils::make_config(&["--syntax-theme", "none", "--width", "variable"]); let input = ADDED_FILE_INPUT.replace("a.py", "a"); let output = integration_test_utils::get_line_of_code_from_delta(&input, 12, " class X:", &config); @@ -87,7 +82,7 @@ mod tests { #[test] fn test_diff_unified_two_files() { - let config = integration_test_utils::get_config(); + let config = integration_test_utils::make_config(&[]); let output = integration_test_utils::run_delta(DIFF_UNIFIED_TWO_FILES, &config); let output = strip_ansi_codes(&output); let mut lines = output.split('\n'); @@ -106,7 +101,7 @@ mod tests { #[test] fn test_diff_unified_two_directories() { - let config = integration_test_utils::get_config(); + let config = integration_test_utils::make_config(&[]); let output = integration_test_utils::run_delta(DIFF_UNIFIED_TWO_DIRECTORIES, &config); let output = strip_ansi_codes(&output); let mut lines = output.split('\n'); @@ -134,7 +129,7 @@ mod tests { #[test] #[ignore] // Ideally, delta would make this test pass. See #121. fn test_delta_ignores_non_diff_input() { - let config = integration_test_utils::get_config(); + let config = integration_test_utils::make_config(&[]); let output = integration_test_utils::run_delta(NOT_A_DIFF_OUTPUT, &config); let output = strip_ansi_codes(&output); assert_eq!(output, NOT_A_DIFF_OUTPUT.to_owned() + "\n"); @@ -146,7 +141,7 @@ mod tests { DIFF_WITH_UNRECOGNIZED_PRECEDING_MATERIAL_1, DIFF_WITH_UNRECOGNIZED_PRECEDING_MATERIAL_2, ] { - let config = integration_test_utils::get_config_from_args(&["--color-only"]); + let config = integration_test_utils::make_config(&["--color-only"]); let output = integration_test_utils::run_delta(input, &config); assert_eq!(strip_ansi_codes(&output), input); assert_ne!(output, input); @@ -155,7 +150,7 @@ mod tests { #[test] fn test_diff_with_merge_conflict_is_not_truncated() { - let config = integration_test_utils::get_config(); + let config = integration_test_utils::make_config(&[]); let output = integration_test_utils::run_delta(DIFF_WITH_MERGE_CONFLICT, &config); // TODO: The + in the first column is being removed. assert!(strip_ansi_codes(&output).contains("+>>>>>>> Stashed changes")); @@ -164,14 +159,14 @@ mod tests { #[test] fn test_diff_with_merge_conflict_is_passed_on_unchanged_under_color_only() { - let config = integration_test_utils::get_config_from_args(&["--color-only"]); + let config = integration_test_utils::make_config(&["--color-only"]); let output = integration_test_utils::run_delta(DIFF_WITH_MERGE_CONFLICT, &config); assert_eq!(strip_ansi_codes(&output), DIFF_WITH_MERGE_CONFLICT); } #[test] fn test_submodule_contains_untracked_content() { - let config = integration_test_utils::get_config(); + let config = integration_test_utils::make_config(&[]); let output = integration_test_utils::run_delta(SUBMODULE_CONTAINS_UNTRACKED_CONTENT_INPUT, &config); let output = strip_ansi_codes(&output); @@ -180,7 +175,7 @@ mod tests { #[test] fn test_triple_dash_at_beginning_of_line_in_code() { - let config = integration_test_utils::get_config(); + let config = integration_test_utils::make_config(&[]); let output = integration_test_utils::run_delta(TRIPLE_DASH_AT_BEGINNING_OF_LINE_IN_CODE, &config); let output = strip_ansi_codes(&output); @@ -191,7 +186,7 @@ mod tests { #[test] fn test_binary_files_differ() { - let config = integration_test_utils::get_config(); + let config = integration_test_utils::make_config(&[]); let output = integration_test_utils::run_delta(BINARY_FILES_DIFFER, &config); let output = strip_ansi_codes(&output); assert!(output.contains("Binary files /dev/null and b/foo differ\n")); @@ -199,7 +194,7 @@ mod tests { #[test] fn test_diff_in_diff() { - let config = integration_test_utils::get_config(); + let config = integration_test_utils::make_config(&[]); let output = integration_test_utils::run_delta(DIFF_IN_DIFF, &config); let output = strip_ansi_codes(&output); assert!(output.contains("\n ---\n")); @@ -208,7 +203,7 @@ mod tests { #[test] fn test_commit_style_raw_no_decoration() { - let config = integration_test_utils::get_config_from_args(&[ + let config = integration_test_utils::make_config(&[ "--commit-style", "raw", "--commit-decoration-style", @@ -229,7 +224,7 @@ commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e #[test] fn test_commit_style_colored_input_color_is_stripped_under_normal() { - let config = integration_test_utils::get_config_from_args(&[ + let config = integration_test_utils::make_config(&[ "--commit-style", "normal", "--commit-decoration-style", @@ -248,7 +243,7 @@ commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e #[test] fn test_commit_style_colored_input_color_is_preserved_under_raw() { - let config = integration_test_utils::get_config_from_args(&[ + let config = integration_test_utils::make_config(&[ "--commit-style", "raw", "--commit-decoration-style", @@ -269,27 +264,26 @@ commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e #[test] fn test_commit_decoration_style_omit() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_commit_style_no_decoration(&[ "--commit-style", "blue", "--commit-decoration-style", "omit", ]); - _do_test_commit_style_no_decoration(config); } #[test] fn test_commit_decoration_style_empty_string() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_commit_style_no_decoration(&[ "--commit-style", "blue", "--commit-decoration-style", "", ]); - _do_test_commit_style_no_decoration(config); } - fn _do_test_commit_style_no_decoration(config: config::Config) { + fn _do_test_commit_style_no_decoration(args: &[&str]) { + let config = integration_test_utils::make_config(args); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); if false { // `--commit-style xxx` is not honored yet: always behaves like xxx=raw @@ -313,7 +307,7 @@ commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e #[test] fn test_commit_style_omit() { - let config = integration_test_utils::get_config_from_args(&["--commit-style", "omit"]); + let config = integration_test_utils::make_config(&["--commit-style", "omit"]); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); let output = strip_ansi_codes(&output); assert!(!output.contains( @@ -325,50 +319,42 @@ commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e #[test] fn test_commit_style_box() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_commit_style_box(&[ "--commit-style", "blue", "--commit-decoration-style", "blue box", ]); - _do_test_commit_style_box(config); } #[test] fn test_commit_style_box_ul() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_commit_style_box_ul(&[ "--commit-style", "blue", "--commit-decoration-style", "blue box ul", ]); - _do_test_commit_style_box_ul(config); } #[ignore] #[test] fn test_commit_style_box_ol() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_commit_style_box_ol(&[ "--commit-style", "blue", "--commit-decoration-style", "blue box ol", ]); - _do_test_commit_style_box_ol(config); } #[test] fn test_commit_style_box_ul_deprecated_options() { - let config = integration_test_utils::get_config_from_args(&[ - "--commit-color", - "blue", - "--commit-style", - "box", - ]); - _do_test_commit_style_box_ul(config); + _do_test_commit_style_box_ul(&["--commit-color", "blue", "--commit-style", "box"]); } - fn _do_test_commit_style_box(config: config::Config) { + fn _do_test_commit_style_box(args: &[&str]) { + let config = integration_test_utils::make_config(args); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); ansi_test_utils::assert_line_has_style( &output, @@ -401,7 +387,8 @@ commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e │ )); } - fn _do_test_commit_style_box_ul(config: config::Config) { + fn _do_test_commit_style_box_ul(args: &[&str]) { + let config = integration_test_utils::make_config(args); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); ansi_test_utils::assert_line_has_style( &output, @@ -433,7 +420,8 @@ commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e │ )); } - fn _do_test_commit_style_box_ol(config: config::Config) { + fn _do_test_commit_style_box_ol(args: &[&str]) { + let config = integration_test_utils::make_config(args); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); ansi_test_utils::assert_line_has_style( &output, @@ -468,7 +456,7 @@ commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e │ #[test] fn test_commit_style_box_raw() { - let config = integration_test_utils::get_config_from_args(&[ + let config = integration_test_utils::make_config(&[ "--commit-style", "raw", "--commit-decoration-style", @@ -492,27 +480,26 @@ commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e │ #[test] fn test_commit_style_underline() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_commit_style_underline(&[ "--commit-style", "yellow", "--commit-decoration-style", "yellow underline", ]); - _do_test_commit_style_underline(config); } #[test] fn test_commit_style_underline_deprecated_options() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_commit_style_underline(&[ "--commit-color", "yellow", "--commit-style", "underline", ]); - _do_test_commit_style_underline(config); } - fn _do_test_commit_style_underline(config: config::Config) { + fn _do_test_commit_style_underline(args: &[&str]) { + let config = integration_test_utils::make_config(args); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); ansi_test_utils::assert_line_has_style( &output, @@ -538,7 +525,7 @@ commit 94907c0f136f46dc46ffae2dc92dca9af7eb7c2e #[test] fn test_file_style_raw_no_decoration() { - let config = integration_test_utils::get_config_from_args(&[ + let config = integration_test_utils::make_config(&[ "--file-style", "raw", "--file-decoration-style", @@ -568,7 +555,7 @@ index 8e37a9e..6ce4863 100644 #[test] fn test_file_style_colored_input_color_is_stripped_under_normal() { - let config = integration_test_utils::get_config_from_args(&[ + let config = integration_test_utils::make_config(&[ "--file-style", "normal", "--file-decoration-style", @@ -583,7 +570,7 @@ index 8e37a9e..6ce4863 100644 #[test] fn test_file_style_colored_input_color_is_preserved_under_raw() { - let config = integration_test_utils::get_config_from_args(&[ + let config = integration_test_utils::make_config(&[ "--file-style", "raw", "--file-decoration-style", @@ -608,27 +595,26 @@ index 8e37a9e..6ce4863 100644 #[test] fn test_file_decoration_style_omit() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_file_style_no_decoration(&[ "--file-style", "green", "--file-decoration-style", "omit", ]); - _do_test_file_style_no_decoration(config); } #[test] fn test_file_decoration_style_empty_string() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_file_style_no_decoration(&[ "--file-style", "green", "--file-decoration-style", "", ]); - _do_test_file_style_no_decoration(config); } - fn _do_test_file_style_no_decoration(config: config::Config) { + fn _do_test_file_style_no_decoration(args: &[&str]) { + let config = integration_test_utils::make_config(args); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); ansi_test_utils::assert_line_has_style(&output, 7, "src/align.rs", "green", &config); let output = strip_ansi_codes(&output); @@ -643,57 +629,49 @@ src/align.rs #[test] fn test_file_style_omit() { - let config = integration_test_utils::get_config_from_args(&["--file-style", "omit"]); + let config = integration_test_utils::make_config(&["--file-style", "omit"]); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); assert!(!output.contains("src/align.rs")); } #[test] fn test_file_style_box() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_file_style_box(&[ "--file-style", "green", "--file-decoration-style", "green box", ]); - _do_test_file_style_box(config); } #[test] fn test_file_style_box_ul() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_file_style_box_ul(&[ "--file-style", "green", "--file-decoration-style", "green box ul", ]); - _do_test_file_style_box_ul(config); } #[ignore] #[test] fn test_file_style_box_ol() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_file_style_box_ol(&[ "--file-style", "green", "--file-decoration-style", "green box ol", ]); - _do_test_file_style_box_ol(config); } #[test] fn test_file_style_box_ul_deprecated_options() { - let config = integration_test_utils::get_config_from_args(&[ - "--file-color", - "green", - "--file-style", - "box", - ]); - _do_test_file_style_box_ul(config); + _do_test_file_style_box_ul(&["--file-color", "green", "--file-style", "box"]); } - fn _do_test_file_style_box(config: config::Config) { + fn _do_test_file_style_box(args: &[&str]) { + let config = integration_test_utils::make_config(args); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); ansi_test_utils::assert_line_has_style(&output, 7, "─────────────┐", "green", &config); ansi_test_utils::assert_line_has_style(&output, 8, "src/align.rs │", "green", &config); @@ -708,7 +686,8 @@ src/align.rs │ )); } - fn _do_test_file_style_box_ul(config: config::Config) { + fn _do_test_file_style_box_ul(args: &[&str]) { + let config = integration_test_utils::make_config(args); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); ansi_test_utils::assert_line_has_style(&output, 7, "─────────────┐", "green", &config); ansi_test_utils::assert_line_has_style(&output, 8, "src/align.rs │", "green", &config); @@ -722,7 +701,8 @@ src/align.rs │ )); } - fn _do_test_file_style_box_ol(config: config::Config) { + fn _do_test_file_style_box_ol(args: &[&str]) { + let config = integration_test_utils::make_config(args); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); ansi_test_utils::assert_line_has_style(&output, 7, "─────────────┬─", "green", &config); ansi_test_utils::assert_line_has_style(&output, 8, "src/align.rs │", "green", &config); @@ -739,7 +719,7 @@ src/align.rs │ #[test] fn test_file_style_box_raw() { - let config = integration_test_utils::get_config_from_args(&[ + let config = integration_test_utils::make_config(&[ "--file-style", "raw", "--file-decoration-style", @@ -757,27 +737,21 @@ src/align.rs │ #[test] fn test_file_style_underline() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_file_style_underline(&[ "--file-style", "magenta", "--file-decoration-style", "magenta underline", ]); - _do_test_file_style_underline(config); } #[test] fn test_file_style_underline_deprecated_options() { - let config = integration_test_utils::get_config_from_args(&[ - "--file-color", - "magenta", - "--file-style", - "underline", - ]); - _do_test_file_style_underline(config); + _do_test_file_style_underline(&["--file-color", "magenta", "--file-style", "underline"]); } - fn _do_test_file_style_underline(config: config::Config) { + fn _do_test_file_style_underline(args: &[&str]) { + let config = integration_test_utils::make_config(args); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); ansi_test_utils::assert_line_has_style(&output, 7, "src/align.rs", "magenta", &config); ansi_test_utils::assert_line_has_style(&output, 8, "────────────", "magenta", &config); @@ -791,7 +765,7 @@ src/align.rs #[test] fn test_hunk_header_style_raw_no_decoration() { - let config = integration_test_utils::get_config_from_args(&[ + let config = integration_test_utils::make_config(&[ "--hunk-header-style", "raw", "--hunk-header-decoration-style", @@ -808,7 +782,7 @@ src/align.rs #[test] fn test_hunk_header_style_colored_input_color_is_stripped_under_normal() { - let config = integration_test_utils::get_config_from_args(&[ + let config = integration_test_utils::make_config(&[ "--hunk-header-style", "normal", "--hunk-header-decoration-style", @@ -825,7 +799,7 @@ src/align.rs #[test] fn test_hunk_header_style_colored_input_color_is_preserved_under_raw() { - let config = integration_test_utils::get_config_from_args(&[ + let config = integration_test_utils::make_config(&[ "--hunk-header-style", "raw", "--hunk-header-decoration-style", @@ -846,30 +820,21 @@ src/align.rs #[test] fn test_hunk_header_decoration_style_omit() { - let config = integration_test_utils::get_config_from_args(&[ - "--hunk-header-decoration-style", - "omit", - ]); - _do_test_hunk_header_style_no_decoration(config); + _do_test_hunk_header_style_no_decoration(&["--hunk-header-decoration-style", "omit"]); } #[test] fn test_hunk_header_decoration_style_none() { - let config = integration_test_utils::get_config_from_args(&[ - "--hunk-header-decoration-style", - "none", - ]); - _do_test_hunk_header_style_no_decoration(config); + _do_test_hunk_header_style_no_decoration(&["--hunk-header-decoration-style", "none"]); } #[test] fn test_hunk_header_decoration_style_empty_string() { - let config = - integration_test_utils::get_config_from_args(&["--hunk-header-decoration-style", ""]); - _do_test_hunk_header_style_no_decoration(config); + _do_test_hunk_header_style_no_decoration(&["--hunk-header-decoration-style", ""]); } - fn _do_test_hunk_header_style_no_decoration(config: config::Config) { + fn _do_test_hunk_header_style_no_decoration(args: &[&str]) { + let config = integration_test_utils::make_config(args); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); let output = strip_ansi_codes(&output); assert!(output.contains(" impl<'a> Alignment<'a> {")); @@ -883,7 +848,7 @@ src/align.rs #[test] fn test_hunk_header_style_omit() { - let config = integration_test_utils::get_config_from_args(&["--hunk-header-style", "omit"]); + let config = integration_test_utils::make_config(&["--hunk-header-style", "omit"]); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); let output = strip_ansi_codes(&output); assert!(!output.contains("impl<'a> Alignment<'a> {")); @@ -891,17 +856,16 @@ src/align.rs #[test] fn test_hunk_header_style_empty_string() { - let config = integration_test_utils::get_config_from_args(&["--hunk-header-style", ""]); - _do_test_hunk_header_empty_style(config); + _do_test_hunk_header_empty_style(&["--hunk-header-style", ""]); } #[test] fn test_hunk_header_style_none() { - let config = integration_test_utils::get_config_from_args(&["--hunk-header-style", "None"]); - _do_test_hunk_header_empty_style(config); + _do_test_hunk_header_empty_style(&["--hunk-header-style", "None"]); } - fn _do_test_hunk_header_empty_style(config: config::Config) { + fn _do_test_hunk_header_empty_style(args: &[&str]) { + let config = integration_test_utils::make_config(args); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); assert!(output.contains(" impl<'a> Alignment<'a> {")); assert!(!output.contains("@@")); @@ -909,25 +873,16 @@ src/align.rs #[test] fn test_hunk_header_style_box() { - let config = integration_test_utils::get_config_from_args(&[ - "--hunk-header-decoration-style", - "white box", - ]); - _do_test_hunk_header_style_box(config); + _do_test_hunk_header_style_box(&["--hunk-header-decoration-style", "white box"]); } #[test] fn test_hunk_header_style_box_deprecated_options() { - let config = integration_test_utils::get_config_from_args(&[ - "--hunk-color", - "white", - "--hunk-style", - "box", - ]); - _do_test_hunk_header_style_box(config); + _do_test_hunk_header_style_box(&["--hunk-color", "white", "--hunk-style", "box"]); } - fn _do_test_hunk_header_style_box(config: config::Config) { + fn _do_test_hunk_header_style_box(args: &[&str]) { + let config = integration_test_utils::make_config(args); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); ansi_test_utils::assert_line_has_style( &output, @@ -955,7 +910,7 @@ src/align.rs #[test] fn test_hunk_header_style_box_raw() { - let config = integration_test_utils::get_config_from_args(&[ + let config = integration_test_utils::make_config(&[ "--hunk-header-style", "raw", "--hunk-header-decoration-style", @@ -978,25 +933,24 @@ src/align.rs #[test] fn test_hunk_header_style_underline() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_hunk_header_style_underline(&[ "--hunk-header-decoration-style", "black underline", ]); - _do_test_hunk_header_style_underline(config); } #[test] fn test_hunk_header_style_underline_deprecated_options() { - let config = integration_test_utils::get_config_from_args(&[ + _do_test_hunk_header_style_underline(&[ "--hunk-color", "black", "--hunk-style", "underline", ]); - _do_test_hunk_header_style_underline(config); } - fn _do_test_hunk_header_style_underline(config: config::Config) { + fn _do_test_hunk_header_style_underline(args: &[&str]) { + let config = integration_test_utils::make_config(args); let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config); ansi_test_utils::assert_line_has_style( &output, @@ -1017,7 +971,7 @@ src/align.rs fn test_hunk_header_style_box_with_syntax_highlighting() { // For this test we are currently forced to disable styling of the decoration, since // otherwise it will confuse assert_line_is_syntax_highlighted. - let config = integration_test_utils::get_config_from_args(&[ + let config = integration_test_utils::make_config(&[ "--hunk-header-style", "syntax", "--hunk-header-decoration-style", |