Skip to content

Commit

Permalink
Fix coverage of errors.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Finomnis committed Oct 21, 2023
1 parent c8722d7 commit 9de8b95
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/errors/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ use crate::BoxedError;

use super::*;

fn examine_report(report: miette::Report) {
fn examine_report(
error: impl miette::Diagnostic + std::error::Error + std::fmt::Debug + Sync + Send + 'static,
) {
println!("{}", error);
println!("{:?}", error);
// Convert to report
let report: miette::Report = error.into();
println!("{}", report);
println!("{:?}", report);
// Convert to std::error::Error
Expand All @@ -13,14 +19,21 @@ fn examine_report(report: miette::Report) {

#[test]
fn errors_can_be_converted_to_diagnostic() {
examine_report(GracefulShutdownError::ShutdownTimeout::<BoxedError>(Box::new([])).into());
examine_report(GracefulShutdownError::SubsystemsFailed::<BoxedError>(Box::new([])).into());
examine_report(SubsystemJoinError::SubsystemsFailed::<BoxedError>(Arc::new([])).into());
examine_report(SubsystemError::Panicked::<BoxedError>("".into()).into());
examine_report(
SubsystemError::Failed::<BoxedError>("".into(), SubsystemFailure("".into())).into(),
);
examine_report(CancelledByShutdown.into());
examine_report(GracefulShutdownError::ShutdownTimeout::<BoxedError>(
Box::new([]),
));
examine_report(GracefulShutdownError::SubsystemsFailed::<BoxedError>(
Box::new([]),
));
examine_report(SubsystemJoinError::SubsystemsFailed::<BoxedError>(
Arc::new([]),
));
examine_report(SubsystemError::Panicked::<BoxedError>("".into()));
examine_report(SubsystemError::Failed::<BoxedError>(
"".into(),
SubsystemFailure("".into()),
));
examine_report(CancelledByShutdown);
}

#[test]
Expand Down

0 comments on commit 9de8b95

Please sign in to comment.