summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorulwlu <ooulwluoo@gmail.com>2021-08-21 01:51:24 +0900
committerGitHub <noreply@github.com>2021-08-20 09:51:24 -0700
commit9fa449e2b530d644f3156cd7b85141c43fea8b8a (patch)
treedef025b0bf160a13156cb8abc923e9562e7aaea9 /src/config.rs
parentea3417abe4d7ab6399254263ec42aae2fb986512 (diff)
Fix computed values to be computed after all set_options (#690)
* Make truecolor option honorable from gitconfig * Add test that true-color can be read from git config The new test fails before 7ed3c2c3ee494dab25fd76b220da7c716a9b731f * Place computing process after set_options * Add test for checking if values requre computing set correctly * Remove unnecessary computed values candidate Co-authored-by: Dan Davison <dandavison7@gmail.com>
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
index 573a08ed..9dfea5d4 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -496,3 +496,37 @@ pub fn delta_unreachable(message: &str) -> ! {
);
process::exit(error_exit_code);
}
+
+#[cfg(test)]
+pub mod tests {
+ use crate::bat_utils::output::PagingMode;
+ use crate::cli;
+ use crate::tests::integration_test_utils;
+ use std::fs::remove_file;
+
+ #[test]
+ fn test_get_computed_values_from_config() {
+ let git_config_contents = b"
+[delta]
+ true-color = never
+ width = 100
+ inspect-raw-lines = true
+ paging = never
+ syntax-theme = None
+";
+ let git_config_path = "delta__test_get_true_color_from_config.gitconfig";
+ let config = integration_test_utils::make_config_from_args_and_git_config(
+ &[],
+ Some(git_config_contents),
+ Some(git_config_path),
+ );
+ assert_eq!(config.true_color, false);
+ assert_eq!(config.decorations_width, cli::Width::Fixed(100));
+ assert_eq!(config.background_color_extends_to_terminal_width, true);
+ assert_eq!(config.inspect_raw_lines, cli::InspectRawLines::True);
+ assert_eq!(config.paging_mode, PagingMode::Never);
+ assert!(config.syntax_theme.is_none());
+ // syntax_set doesn't depend on gitconfig.
+ remove_file(git_config_path).unwrap();
+ }
+}