mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-18 01:40:34 +01:00
Add unit tests for merge_exitcodes
This commit is contained in:
parent
232e3937f2
commit
0f2429cabc
3 changed files with 30 additions and 2 deletions
|
@ -7,7 +7,7 @@
|
|||
// according to those terms.
|
||||
|
||||
use super::CommandTemplate;
|
||||
use crate::exit_codes::{ExitCode, merge_exitcodes};
|
||||
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
||||
use crate::walk::WorkerResult;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::mpsc::Receiver;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#[derive(PartialEq, Debug)]
|
||||
pub enum ExitCode {
|
||||
Success,
|
||||
GeneralError,
|
||||
|
@ -29,3 +30,30 @@ pub fn merge_exitcodes(results: Vec<ExitCode>) -> ExitCode {
|
|||
}
|
||||
ExitCode::Success
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn success_with_empty_vec() {
|
||||
assert_eq!(merge_exitcodes(vec![]), ExitCode::Success);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn general_error_with_at_least_a_matching_error() {
|
||||
assert_eq!(
|
||||
merge_exitcodes(vec![ExitCode::KilledBySigint, ExitCode::Success]),
|
||||
ExitCode::GeneralError
|
||||
);
|
||||
assert_eq!(
|
||||
merge_exitcodes(vec![ExitCode::GeneralError, ExitCode::Success]),
|
||||
ExitCode::GeneralError
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn success_with_no_error() {
|
||||
assert_eq!(merge_exitcodes(vec![ExitCode::Success]), ExitCode::Success);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
// according to those terms.
|
||||
|
||||
use crate::exec;
|
||||
use crate::exit_codes::{ExitCode, merge_exitcodes};
|
||||
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
||||
use crate::fshelper;
|
||||
use crate::internal::{opts::FdOptions, osstr_to_bytes, MAX_BUFFER_LENGTH};
|
||||
use crate::output;
|
||||
|
|
Loading…
Reference in a new issue