Skip to content

Commit

Permalink
test: 🔍 🔨 make test name more clear, add reverse sort false
Browse files Browse the repository at this point in the history
Signed-off-by: zwPapEr <[email protected]>
  • Loading branch information
zwpaper committed Dec 10, 2020
1 parent 9918fc9 commit f701655
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/flags/recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ mod test {
use clap::ErrorKind;

#[test]
fn test_enabled_from_arg_matches_none() {
fn test_enabled_from_arg_matches_empty() {
let argv = vec!["lsd"];
let matches = app::build().get_matches_from_safe(argv).unwrap();
assert_eq!(None, Recursion::enabled_from_arg_matches(&matches));
Expand All @@ -147,7 +147,7 @@ mod test {
}

#[test]
fn test_enabled_from_config_empty() {
fn test_enabled_from_empty_matches_and_config() {
let argv = vec!["lsd"];
assert_eq!(
false,
Expand All @@ -159,7 +159,7 @@ mod test {
}

#[test]
fn test_enabled_from_config_true() {
fn test_enabled_from_matches_empty_and_config_true() {
let argv = vec!["lsd"];
let mut c = Config::with_none();
c.recursion = Some(config_file::Recursion {
Expand All @@ -173,7 +173,7 @@ mod test {
}

#[test]
fn test_enabled_from_config_false() {
fn test_enabled_from_matches_empty_and_config_false() {
let argv = vec!["lsd"];
let mut c = Config::with_none();
c.recursion = Some(config_file::Recursion {
Expand All @@ -190,7 +190,7 @@ mod test {
// of the assert_eq macro, because clap::Error does not implement PartialEq.

#[test]
fn test_depth_from_arg_matches_none() {
fn test_depth_from_arg_matches_empty() {
let argv = vec!["lsd"];
let matches = app::build().get_matches_from_safe(argv).unwrap();
assert!(match Recursion::depth_from_arg_matches(&matches) {
Expand Down
13 changes: 12 additions & 1 deletion src/flags/sorting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ mod test_sort_order {
}

#[test]
fn test_from_config_reverse() {
fn test_from_config_reverse_true() {
let mut c = Config::with_none();
c.sorting = Some(Sorting {
column: None,
Expand All @@ -429,6 +429,17 @@ mod test_sort_order {
});
assert_eq!(Some(SortOrder::Reverse), SortOrder::from_config(&c));
}

#[test]
fn test_from_config_reverse_false() {
let mut c = Config::with_none();
c.sorting = Some(Sorting {
column: None,
reverse: Some(false),
dir_grouping: None,
});
assert_eq!(Some(SortOrder::Default), SortOrder::from_config(&c));
}
}

#[cfg(test)]
Expand Down

0 comments on commit f701655

Please sign in to comment.