mirror of https://github.com/sharkdp/fd.git
Add unit tests for merge_exitcodes
This commit is contained in:
parent
232e3937f2
commit
0f2429cabc
|
@ -7,7 +7,7 @@
|
||||||
// according to those terms.
|
// according to those terms.
|
||||||
|
|
||||||
use super::CommandTemplate;
|
use super::CommandTemplate;
|
||||||
use crate::exit_codes::{ExitCode, merge_exitcodes};
|
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
||||||
use crate::walk::WorkerResult;
|
use crate::walk::WorkerResult;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::mpsc::Receiver;
|
use std::sync::mpsc::Receiver;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#[derive(PartialEq, Debug)]
|
||||||
pub enum ExitCode {
|
pub enum ExitCode {
|
||||||
Success,
|
Success,
|
||||||
GeneralError,
|
GeneralError,
|
||||||
|
@ -29,3 +30,30 @@ pub fn merge_exitcodes(results: Vec<ExitCode>) -> ExitCode {
|
||||||
}
|
}
|
||||||
ExitCode::Success
|
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.
|
// according to those terms.
|
||||||
|
|
||||||
use crate::exec;
|
use crate::exec;
|
||||||
use crate::exit_codes::{ExitCode, merge_exitcodes};
|
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
||||||
use crate::fshelper;
|
use crate::fshelper;
|
||||||
use crate::internal::{opts::FdOptions, osstr_to_bytes, MAX_BUFFER_LENGTH};
|
use crate::internal::{opts::FdOptions, osstr_to_bytes, MAX_BUFFER_LENGTH};
|
||||||
use crate::output;
|
use crate::output;
|
||||||
|
|
Loading…
Reference in New Issue