use pretty_assertions::assert_eq;
use super::with_causes;
#[derive(Debug, thiserror::Error)]
#[error("error sending request")]
struct Hides(#[source] std::io::Error);
#[derive(Debug, thiserror::Error)]
#[error("Io error: {0}")]
struct Shows(#[source] std::io::Error);
#[test]
fn causes_are_appended_once() {
let refused = || std::io::Error::new(std::io::ErrorKind::ConnectionRefused, "refused");
assert_eq!(
(
with_causes(&Hides(refused())),
with_causes(&Shows(refused()))
),
(
"error sending request: refused".to_owned(),
"Io error: refused".to_owned()
)
);
}