public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox] proxmox/tools/email: adapt tests to changes to sendmail
@ 2021-05-14  8:39 Dominik Csapak
  2021-05-14  9:35 ` [pbs-devel] applied: " Thomas Lamprecht
  2021-05-14  9:38 ` [pbs-devel] " Thomas Lamprecht
  0 siblings, 2 replies; 3+ messages in thread
From: Dominik Csapak @ 2021-05-14  8:39 UTC (permalink / raw)
  To: pbs-devel

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





^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pbs-devel] applied: [PATCH proxmox] proxmox/tools/email: adapt tests to changes to sendmail
  2021-05-14  8:39 [pbs-devel] [PATCH proxmox] proxmox/tools/email: adapt tests to changes to sendmail Dominik Csapak
@ 2021-05-14  9:35 ` Thomas Lamprecht
  2021-05-14  9:38 ` [pbs-devel] " Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2021-05-14  9:35 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

On 14.05.21 10:39, Dominik Csapak wrote:
> 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(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pbs-devel] [PATCH proxmox] proxmox/tools/email: adapt tests to changes to sendmail
  2021-05-14  8:39 [pbs-devel] [PATCH proxmox] proxmox/tools/email: adapt tests to changes to sendmail Dominik Csapak
  2021-05-14  9:35 ` [pbs-devel] applied: " Thomas Lamprecht
@ 2021-05-14  9:38 ` Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2021-05-14  9:38 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

On 14.05.21 10:39, Dominik Csapak wrote:
> the first/last test now generate real emails to root@localhost,
> if we do not want that, we should remove those tests entirely

Saw this to late, def. never wanted - such things should then be mocked!

I just drop those test for now, not really useful anyway.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-14  9:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14  8:39 [pbs-devel] [PATCH proxmox] proxmox/tools/email: adapt tests to changes to sendmail Dominik Csapak
2021-05-14  9:35 ` [pbs-devel] applied: " Thomas Lamprecht
2021-05-14  9:38 ` [pbs-devel] " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal