From c16a378482b42395c4763946a0a13fe62087fdff Mon Sep 17 00:00:00 2001 From: Tibor Date: Fri, 19 Nov 2021 09:02:18 +0000 Subject: [PATCH] tests: add tests for creating errors --- src/error.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/error.rs b/src/error.rs index 9e0e720..5c32310 100644 --- a/src/error.rs +++ b/src/error.rs @@ -139,3 +139,34 @@ where } } } + +#[test] +fn create_permanent_error() { + let e = Error::permanent("err"); + assert_eq!(e, Error::Permanent("err")); +} + +#[test] +fn create_transient_error() { + let e = Error::transient("err"); + assert_eq!( + e, + Error::Transient { + err: "err", + retry_after: None + } + ); +} + +#[test] +fn create_transient_error_with_retry_after() { + let retry_after = Duration::from_secs(42); + let e = Error::retry_after("err", retry_after); + assert_eq!( + e, + Error::Transient { + err: "err", + retry_after: Some(retry_after), + } + ); +}