test: improve test coverage
All checks were successful
Publish Docker Images / build-and-publish (push) Successful in 8m4s
All checks were successful
Publish Docker Images / build-and-publish (push) Successful in 8m4s
This commit is contained in:
@@ -646,4 +646,76 @@ mod tests {
|
||||
assert!(debug_output.contains("smtp.example.com"));
|
||||
assert!(debug_output.contains("user@example.com"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn email_settings_try_sender_into_mailbox_success() {
|
||||
let settings = EmailSettings {
|
||||
host: "smtp.example.com".to_string(),
|
||||
port: 587,
|
||||
user: "user@example.com".to_string(),
|
||||
from: "sender@example.com".to_string(),
|
||||
password: "password".to_string(),
|
||||
recipient: "recipient@example.com".to_string(),
|
||||
starttls: Starttls::Always,
|
||||
tls: false,
|
||||
};
|
||||
|
||||
let result = settings.try_sender_into_mailbox();
|
||||
assert!(result.is_ok());
|
||||
let mailbox = result.unwrap();
|
||||
assert_eq!(mailbox.email.to_string(), "sender@example.com");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn email_settings_try_sender_into_mailbox_invalid() {
|
||||
let settings = EmailSettings {
|
||||
host: "smtp.example.com".to_string(),
|
||||
port: 587,
|
||||
user: "user@example.com".to_string(),
|
||||
from: "invalid-email".to_string(),
|
||||
password: "password".to_string(),
|
||||
recipient: "recipient@example.com".to_string(),
|
||||
starttls: Starttls::Always,
|
||||
tls: false,
|
||||
};
|
||||
|
||||
let result = settings.try_sender_into_mailbox();
|
||||
assert!(result.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn email_settings_try_recipient_into_mailbox_success() {
|
||||
let settings = EmailSettings {
|
||||
host: "smtp.example.com".to_string(),
|
||||
port: 587,
|
||||
user: "user@example.com".to_string(),
|
||||
from: "sender@example.com".to_string(),
|
||||
password: "password".to_string(),
|
||||
recipient: "recipient@example.com".to_string(),
|
||||
starttls: Starttls::Always,
|
||||
tls: false,
|
||||
};
|
||||
|
||||
let result = settings.try_recpient_into_mailbox();
|
||||
assert!(result.is_ok());
|
||||
let mailbox = result.unwrap();
|
||||
assert_eq!(mailbox.email.to_string(), "recipient@example.com");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn email_settings_try_recipient_into_mailbox_invalid() {
|
||||
let settings = EmailSettings {
|
||||
host: "smtp.example.com".to_string(),
|
||||
port: 587,
|
||||
user: "user@example.com".to_string(),
|
||||
from: "sender@example.com".to_string(),
|
||||
password: "password".to_string(),
|
||||
recipient: "invalid-email".to_string(),
|
||||
starttls: Starttls::Always,
|
||||
tls: false,
|
||||
};
|
||||
|
||||
let result = settings.try_recpient_into_mailbox();
|
||||
assert!(result.is_err());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user