summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorryuta69 <eyma22s.yu@gmail.com>2020-09-19 00:00:52 +0900
committerGitHub <noreply@github.com>2020-09-18 11:00:52 -0400
commit3b5c89fcbc6efc2a346dfbd2cc2c49fcdae8a0b0 (patch)
tree24f15c8cfec6cb50d3879e923fb311dac09bcfb4 /src/tests
parentdd88342018aa239c77d7667bc988f0ff5db4610a (diff)
Fix `git add -p` to work when any options enabled (#323)
* Add test for input and output for diff interactive filter * Add color_only in config struct * Refactor should_handle false when color_only and FileMeta, CommitMeta * Refactor handle_hunk_header_line to show raw_text with color_format when color_only * Fix indent * Revert the logic changes for interactive filter * Add color only workaround in set options * Add more test patterns for diff interactive fillter
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test_example_diffs.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/tests/test_example_diffs.rs b/src/tests/test_example_diffs.rs
index 9f1a257f..e7a00ee3 100644
--- a/src/tests/test_example_diffs.rs
+++ b/src/tests/test_example_diffs.rs
@@ -836,6 +836,50 @@ src/align.rs
}
#[test]
+ fn test_color_only_output_is_in_one_to_one_correspondence_with_input() {
+ _do_test_output_is_in_one_to_one_correspondence_with_input(&["--color-only", "true"]);
+ _do_test_output_is_in_one_to_one_correspondence_with_input(&[
+ "--color-only",
+ "true",
+ "--file-style",
+ "blue",
+ "--commit-style",
+ "omit",
+ "--hunk-header-style",
+ "omit",
+ "--hunk-header-decoration-style",
+ "omit",
+ ]);
+ _do_test_output_is_in_one_to_one_correspondence_with_input(&[
+ "--color-only",
+ "true",
+ "--file-style",
+ "blue",
+ "--commit-style",
+ "red",
+ "--hunk-header-style",
+ "syntax",
+ "--hunk-header-decoration-style",
+ "box",
+ ]);
+ }
+
+ fn _do_test_output_is_in_one_to_one_correspondence_with_input(args: &[&str]) {
+ let config = integration_test_utils::make_config_from_args(args);
+ let output = integration_test_utils::run_delta(GIT_DIFF_SINGLE_HUNK, &config);
+
+ let output = strip_ansi_codes(&output);
+ let output_lines: Vec<&str> = output.split('\n').collect();
+ let input_lines: Vec<&str> = GIT_DIFF_SINGLE_HUNK.split('\n').collect();
+
+ assert_eq!(input_lines.len(), output_lines.len());
+
+ for n in 0..input_lines.len() {
+ assert_eq!(input_lines[n], output_lines[n]);
+ }
+ }
+
+ #[test]
fn test_hunk_header_style_colored_input_color_is_stripped_under_normal() {
let config = integration_test_utils::make_config_from_args(&[
"--hunk-header-style",