test: improve test coverage
All checks were successful
Publish Docker Images / build-and-publish (push) Successful in 8m4s

This commit is contained in:
2025-11-15 23:18:03 +01:00
parent 0964843c49
commit a3abe0f716
3 changed files with 774 additions and 0 deletions

View File

@@ -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());
}
}