[pbs-devel] [PATCH proxmox] proxmox/tools/email: adapt tests to changes to sendmail
Dominik Csapak
d.csapak at proxmox.com
Fri May 14 10:39:29 CEST 2021
with test1/3 we only tested the regex, which is now gone
transform the tests to valid emails, so we test this also
and rename them to know what they should test
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
the first/last test now generate real emails to root at localhost,
if we do not want that, we should remove those tests entirely
proxmox/src/tools/email.rs | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/proxmox/src/tools/email.rs b/proxmox/src/tools/email.rs
index 0b92a5b..fc69488 100644
--- a/proxmox/src/tools/email.rs
+++ b/proxmox/src/tools/email.rs
@@ -113,20 +113,20 @@ mod test {
use crate::tools::email::sendmail;
#[test]
- fn test1() {
+ fn send_email_to_root_localhost() {
let result = sendmail(
- &["somenotvalidemail!", "somealmostvalid email"],
+ &["root at localhost"],
"Subject1",
Some("TEXT"),
Some("<b>HTML</b>"),
- Some("bim at bam.bum"),
+ Some("root at localhost"),
Some("test1"),
);
- assert!(result.is_err());
+ assert!(result.is_ok());
}
#[test]
- fn test2() {
+ fn email_without_recipients() {
let result = sendmail(
&[],
"Subject2",
@@ -139,15 +139,15 @@ mod test {
}
#[test]
- fn test3() {
+ fn email_with_non_existant_recipient() {
let result = sendmail(
- &["a at b.c"],
+ &["some-nonexistant-proxmox-user"],
"Subject3",
None,
Some("<b>HTML</b>"),
- Some("notv at lid.com!"),
+ None,
Some("test1"),
);
- assert!(result.is_err());
+ assert!(result.is_ok());
}
}
--
2.20.1
More information about the pbs-devel
mailing list