Use the notify script in tests

Instead of only checking whether the notification script is called with
the correct parameters, actually invoke the real notify script and check
whether proper notifications are generated.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Lukas Fleischer 2016-09-29 20:45:58 +02:00
parent e1709e98ce
commit eb367d97e2
2 changed files with 15 additions and 10 deletions

View file

@ -15,6 +15,7 @@ MKPKGLISTS="$TOPLEVEL/scripts/mkpkglists.py"
TUVOTEREMINDER="$TOPLEVEL/scripts/tuvotereminder.py" TUVOTEREMINDER="$TOPLEVEL/scripts/tuvotereminder.py"
PKGMAINT="$TOPLEVEL/scripts/pkgmaint.py" PKGMAINT="$TOPLEVEL/scripts/pkgmaint.py"
AURBLUP="$TOPLEVEL/scripts/aurblup.py" AURBLUP="$TOPLEVEL/scripts/aurblup.py"
NOTIFY="$TOPLEVEL/scripts/notify.py"
# Create the configuration file and a dummy notification script. # Create the configuration file and a dummy notification script.
cat >config <<-EOF cat >config <<-EOF
@ -23,11 +24,16 @@ backend = sqlite
name = aur.db name = aur.db
[options] [options]
aur_location = https://aur.archlinux.org
aur_request_ml = aur-requests@archlinux.org
enable-maintenance = 0 enable-maintenance = 0
maintenance-exceptions = 127.0.0.1 maintenance-exceptions = 127.0.0.1
[notifications] [notifications]
notify-cmd = ./notify.sh notify-cmd = $NOTIFY
sendmail = ./sendmail.sh
sender = notify@aur.archlinux.org
reply-to = noreply@aur.archlinux.org
[auth] [auth]
valid-keytypes = ssh-rsa ssh-dss ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521 ssh-ed25519 valid-keytypes = ssh-rsa ssh-dss ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521 ssh-ed25519
@ -55,11 +61,11 @@ packagesfile = packages.gz
pkgbasefile = pkgbase.gz pkgbasefile = pkgbase.gz
EOF EOF
cat >notify.sh <<-\EOF cat >sendmail.sh <<-\EOF
#!/bin/sh #!/bin/sh
echo $* >>notify.out cat >>sendmail.out
EOF EOF
chmod +x notify.sh chmod +x sendmail.sh
cat >git-shell.sh <<-\EOF cat >git-shell.sh <<-\EOF
#!/bin/sh #!/bin/sh

View file

@ -14,13 +14,12 @@ test_expect_success 'Test Trusted User vote reminders.' '
INSERT INTO TU_VoteInfo (ID, Agenda, User, Submitted, End, Quorum, SubmitterID) VALUES (3, "Lorem ipsum.", "user", 0, $tomorrow, 0.00, 2); INSERT INTO TU_VoteInfo (ID, Agenda, User, Submitted, End, Quorum, SubmitterID) VALUES (3, "Lorem ipsum.", "user", 0, $tomorrow, 0.00, 2);
INSERT INTO TU_VoteInfo (ID, Agenda, User, Submitted, End, Quorum, SubmitterID) VALUES (4, "Lorem ipsum.", "user", 0, $threedays, 0.00, 2); INSERT INTO TU_VoteInfo (ID, Agenda, User, Submitted, End, Quorum, SubmitterID) VALUES (4, "Lorem ipsum.", "user", 0, $threedays, 0.00, 2);
EOD EOD
>notify.out && >sendmail.out &&
"$TUVOTEREMINDER" && "$TUVOTEREMINDER" &&
cat <<-EOD >expected && grep -q "Proposal 2" sendmail.out &&
tu-vote-reminder 2 grep -q "Proposal 3" sendmail.out &&
tu-vote-reminder 3 test_must_fail grep -q "Proposal 1" sendmail.out &&
EOD test_must_fail grep -q "Proposal 4" sendmail.out
test_cmp notify.out expected
' '
test_done test_done