summaryrefslogtreecommitdiffstats
path: root/src/features
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-06-22 18:59:22 -0400
committerDan Davison <dandavison7@gmail.com>2020-06-22 19:27:05 -0400
commit623f6a40db8be645bb186e2365f46b10e7b79ff3 (patch)
treec7dc6cba2f1cc5804ce1d8c039cec9590522fe80 /src/features
parent83e020d43e143852aebe1c64e15edd2ba4b13756 (diff)
Tighten up Opt construction in tests
Diffstat (limited to 'src/features')
-rw-r--r--src/features/mod.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/features/mod.rs b/src/features/mod.rs
index e907d037..edf23f88 100644
--- a/src/features/mod.rs
+++ b/src/features/mod.rs
@@ -82,20 +82,17 @@ pub mod tests {
use std::path::Path;
use itertools;
- use structopt::{clap, StructOpt};
use crate::cli;
use crate::features::make_builtin_features;
use crate::git_config::GitConfig;
- use crate::set_options::set_options;
#[test]
fn test_builtin_features_have_flags() {
let builtin_features = make_builtin_features();
let mut args = vec!["delta".to_string()];
args.extend(builtin_features.keys().map(|s| format!("--{}", s)));
- let mut opt = cli::Opt::from_iter(args);
- set_options(&mut opt, &mut None, &clap::ArgMatches::new());
+ let opt = cli::Opt::from_iter_and_git_config(args, &mut None);
let features: HashSet<&str> = opt.features.split_whitespace().collect();
for feature in builtin_features.keys() {
assert!(features.contains(feature.as_str()))
@@ -104,9 +101,7 @@ pub mod tests {
#[test]
fn test_feature_is_not_removed_by_addition_of_another_feature() {
- let dummy_arg_matches = clap::ArgMatches::new();
- let mut opt = cli::Opt::from_iter(&["delta", "--color-only"]);
- set_options(&mut opt, &mut None, &dummy_arg_matches);
+ let opt = cli::Opt::from_iter_and_git_config(&["delta", "--color-only"], &mut None);
let features: HashSet<&str> = opt.features.split_whitespace().collect();
assert!(features.contains("color-only"));
let git_config_contents = b"
@@ -116,7 +111,8 @@ pub mod tests {
let git_config_path =
"delta__test_feature_is_not_removed_by_addition_of_another_feature.gitconfig";
let git_config = make_git_config(git_config_contents, git_config_path);
- set_options(&mut opt, &mut Some(git_config), &dummy_arg_matches);
+ let opt =
+ cli::Opt::from_iter_and_git_config(&["delta", "--color-only"], &mut Some(git_config));
let features: HashSet<&str> = opt.features.split_whitespace().collect();
assert!(features.contains("my-feature"));
assert!(features.contains("color-only"));