Status - complete test coverage

This commit is contained in:
Nathan Fisher 2023-06-07 16:00:03 -04:00
parent 4642443d37
commit 676c7b34dc

View file

@ -68,7 +68,7 @@ pub enum Redirect {
/// The mailbox has moved to a different address, and all future /// The mailbox has moved to a different address, and all future
/// messages should be sent to that address. /// messages should be sent to that address.
Permanent = 1, Permanent = 1,
Other, Other = 2,
} }
impl TryFrom<u8> for Redirect { impl TryFrom<u8> for Redirect {
@ -103,7 +103,7 @@ pub enum TemporaryFailure {
RateLimit = 4, RateLimit = 4,
/// The mailbox isn't accepting mail right now, but it might in the future. /// The mailbox isn't accepting mail right now, but it might in the future.
MailboxFull = 5, MailboxFull = 5,
Other, Other = 6,
} }
impl TryFrom<u8> for TemporaryFailure { impl TryFrom<u8> for TemporaryFailure {
@ -140,7 +140,7 @@ pub enum PermanentFailure {
DomainNotServiced = 3, DomainNotServiced = 3,
/// Your request is malformed, and won't be accepted by the mailserver. /// Your request is malformed, and won't be accepted by the mailserver.
BadRequest = 9, BadRequest = 9,
Other, Other = 4,
} }
impl TryFrom<u8> for PermanentFailure { impl TryFrom<u8> for PermanentFailure {
@ -178,7 +178,7 @@ pub enum AuthenticationFailure {
/// The mailserver needs you to complete a task to confirm that you are a /// The mailserver needs you to complete a task to confirm that you are a
/// legitimate sender. (This is reserved for a Hashcash style anti-spam measure). /// legitimate sender. (This is reserved for a Hashcash style anti-spam measure).
ProofRequired = 4, ProofRequired = 4,
Other, Other = 5,
} }
impl TryFrom<u8> for AuthenticationFailure { impl TryFrom<u8> for AuthenticationFailure {
@ -209,8 +209,40 @@ mod tests {
#[test] #[test]
fn to_number_redirect() { fn to_number_redirect() {
let num: u8 = Status::Redirect(Redirect::Temporary).into(); assert_eq!(u8::from(Status::Redirect(Redirect::Temporary)), 30);
assert_eq!(num, 30); assert_eq!(u8::from(Status::Redirect(Redirect::Permanent)), 31);
assert_eq!(u8::from(Status::Redirect(Redirect::Other)), 32);
}
#[test]
fn to_number_temporary() {
assert_eq!(u8::from(Status::TemporaryFailure(TemporaryFailure::TemporaryError)), 40);
assert_eq!(u8::from(Status::TemporaryFailure(TemporaryFailure::ServerUnavailable)), 41);
assert_eq!(u8::from(Status::TemporaryFailure(TemporaryFailure::CgiError)), 42);
assert_eq!(u8::from(Status::TemporaryFailure(TemporaryFailure::ProxyError)), 43);
assert_eq!(u8::from(Status::TemporaryFailure(TemporaryFailure::RateLimit)), 44);
assert_eq!(u8::from(Status::TemporaryFailure(TemporaryFailure::MailboxFull)), 45);
assert_eq!(u8::from(Status::TemporaryFailure(TemporaryFailure::Other)), 46);
}
#[test]
fn to_number_permanent() {
assert_eq!(u8::from(Status::PermanentFailure(PermanentFailure::PermanentError)), 50);
assert_eq!(u8::from(Status::PermanentFailure(PermanentFailure::MailboxNonexistent)), 51);
assert_eq!(u8::from(Status::PermanentFailure(PermanentFailure::MailboxGone)), 52);
assert_eq!(u8::from(Status::PermanentFailure(PermanentFailure::DomainNotServiced)), 53);
assert_eq!(u8::from(Status::PermanentFailure(PermanentFailure::BadRequest)), 59);
assert_eq!(u8::from(Status::PermanentFailure(PermanentFailure::Other)), 54);
}
#[test]
fn to_number_auth() {
assert_eq!(u8::from(Status::AuthenticationFailure(AuthenticationFailure::CertificateRequired)), 60);
assert_eq!(u8::from(Status::AuthenticationFailure(AuthenticationFailure::UnauthorizedSender)), 61);
assert_eq!(u8::from(Status::AuthenticationFailure(AuthenticationFailure::CertificateInvalid)), 62);
assert_eq!(u8::from(Status::AuthenticationFailure(AuthenticationFailure::IdentityMismatch)), 63);
assert_eq!(u8::from(Status::AuthenticationFailure(AuthenticationFailure::ProofRequired)), 64);
assert_eq!(u8::from(Status::AuthenticationFailure(AuthenticationFailure::Other)), 65);
} }
#[test] #[test]