From 21ff09e2ecfa23dc65a9306114a9b2212759b5b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= <jerome@riseup.net>
Date: Sun, 12 Feb 2023 13:32:52 -0500
Subject: [PATCH] add test for reportemail = no

---
 test/backupninja.bats | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/test/backupninja.bats b/test/backupninja.bats
index b0a5a3e..a8ca55b 100644
--- a/test/backupninja.bats
+++ b/test/backupninja.bats
@@ -3,6 +3,7 @@ load common
 teardown_backupninja() {
     [ -x /usr/bin/mail.moved ] && mv /usr/bin/mail.moved /usr/bin/mail
     [ -x /usr/bin/rsync.moved ] && mv /usr/bin/rsync.moved /usr/bin/rsync
+    rm -f /var/mail/vagrant
 }
 
 create_test_action() {
@@ -235,6 +236,16 @@ create_test_action() {
     [ "$status" -eq 1 ]
 }
 
+@test "reports: email not sent when reportemail is no" {
+    create_test_action info test_info
+    setconfig backupninja.conf reportsuccess yes
+    setconfig backupninja.conf reportinfo yes
+    setconfig backupninja.conf reportemail no
+    run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh"
+    [ "$status" -eq 0 ]
+    ! test -f /var/mail/vagrant
+}
+
 @test "scheduling: runs when = 'everyday at 01' and time matches" {
     create_test_action info test_info
     setconfig backupninja.conf when 'everyday at 01'
-- 
GitLab