diff options
author | Dan Davison <dandavison7@gmail.com> | 2021-12-11 20:54:19 -0500 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2021-12-12 00:20:52 -0500 |
commit | 15e9374b783512969a37bd9e19c2c00ff0648e22 (patch) | |
tree | 7b2932379b901e67e322ee4af2b52209ce3fb985 | |
parent | b732c9419e5327b83338d088b05fa27ccfa8999e (diff) |
Allow calling process to be specified in DeltaTest builder methods
-rw-r--r-- | src/handlers/hunk.rs | 8 | ||||
-rw-r--r-- | src/tests/integration_test_utils.rs | 9 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/handlers/hunk.rs b/src/handlers/hunk.rs index 352b5d70..08fc5f96 100644 --- a/src/handlers/hunk.rs +++ b/src/handlers/hunk.rs @@ -205,19 +205,16 @@ fn new_line_state(new_line: &str, prev_state: &State) -> Option<State> { #[cfg(test)] mod tests { use crate::tests::integration_test_utils::DeltaTest; - use crate::utils::process::tests::FakeParentArgs; mod word_diff { use super::*; #[test] fn test_word_diff() { - let _args = FakeParentArgs::for_scope("git diff --word-diff"); - DeltaTest::with(&[]) + .with_calling_process("git diff --word-diff") .with_input(GIT_DIFF_WORD_DIFF) .explain_ansi() - .inspect() .expect_skip( 11, " @@ -232,9 +229,8 @@ mod tests { #[test] fn test_color_words() { - let _args = FakeParentArgs::for_scope("git diff --color-words"); - DeltaTest::with(&[]) + .with_calling_process("git diff --color-words") .with_input(GIT_DIFF_COLOR_WORDS) .explain_ansi() .expect_skip( diff --git a/src/tests/integration_test_utils.rs b/src/tests/integration_test_utils.rs index 2072c404..d1a7f970 100644 --- a/src/tests/integration_test_utils.rs +++ b/src/tests/integration_test_utils.rs @@ -12,6 +12,7 @@ use crate::cli; use crate::config; use crate::delta::delta; use crate::git_config::GitConfig; +use crate::utils::process::tests::FakeParentArgs; pub fn make_options_from_args_and_git_config( args: &[&str], @@ -127,12 +128,14 @@ pub fn lines_match(expected: &str, have: &str, skip: Option<usize>) { pub struct DeltaTest { config: config::Config, + calling_process: Option<String>, } impl DeltaTest { pub fn with(args: &[&str]) -> Self { Self { config: make_config_from_args(args), + calling_process: None, } } @@ -144,6 +147,11 @@ impl DeltaTest { self } + pub fn with_calling_process(mut self, command: &str) -> Self { + self.calling_process = Some(command.to_string()); + self + } + pub fn with_config_and_input(config: &config::Config, input: &str) -> DeltaTestOutput { DeltaTestOutput { output: run_delta(input, &config), @@ -152,6 +160,7 @@ impl DeltaTest { } pub fn with_input(&self, input: &str) -> DeltaTestOutput { + let _args = FakeParentArgs::for_scope(self.calling_process.as_deref().unwrap_or("")); DeltaTest::with_config_and_input(&self.config, input) } } |