all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox] proxmox/tools/email: adapt tests to changes to sendmail
Date: Fri, 14 May 2021 10:39:29 +0200	[thread overview]
Message-ID: <20210514083929.29664-1-d.csapak@proxmox.com> (raw)

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@proxmox.com>
---
the first/last test now generate real emails to root@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@localhost"],
             "Subject1",
             Some("TEXT"),
             Some("<b>HTML</b>"),
-            Some("bim@bam.bum"),
+            Some("root@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@b.c"],
+            &["some-nonexistant-proxmox-user"],
             "Subject3",
             None,
             Some("<b>HTML</b>"),
-            Some("notv@lid.com!"),
+            None,
             Some("test1"),
         );
-        assert!(result.is_err());
+        assert!(result.is_ok());
     }
 }
-- 
2.20.1





             reply	other threads:[~2021-05-14  8:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14  8:39 Dominik Csapak [this message]
2021-05-14  9:35 ` [pbs-devel] applied: " Thomas Lamprecht
2021-05-14  9:38 ` [pbs-devel] " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210514083929.29664-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal