use topcoat::router::error::{
bad_request, forbidden, internal_server_error, not_found, redirect, unauthorized,
};
use super::*;
#[test]
fn failures_show_their_page() {
assert_eq!(
PanelError::of(¬_found().into()),
Some(PanelError::NotFound)
);
assert_eq!(
PanelError::of(&forbidden().into()),
Some(PanelError::Forbidden)
);
assert_eq!(
PanelError::of(&internal_server_error(topcoat::Error::msg("boom")).into()),
Some(PanelError::Failed)
);
assert_eq!(
PanelError::of(&topcoat::Error::msg("an app's own error")),
Some(PanelError::Failed)
);
}
#[test]
fn answered_errors_pass_through() {
for error in [
redirect("/admin/login").into(),
unauthorized().into(),
bad_request("a malformed form").into(),
] {
assert_eq!(PanelError::of(&error), None, "{error}");
}
}