summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2016-09-21 08:49:18 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2016-09-29 22:07:24 +0200
commitcd2d90612b63711f9d92bff686698b6c37b79b2b (patch)
tree009fa7d1444e1475f913e1be2319057aaa9015a5
parenta48f8ccb131b059e6878efc647a8ebd5f887d7a7 (diff)
Add tests for tuvotereminder
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
-rw-r--r--test/setup.sh4
-rwxr-xr-xtest/t2200-tuvotereminder.sh26
2 files changed, 29 insertions, 1 deletions
diff --git a/test/setup.sh b/test/setup.sh
index 85faba0..e6a9a16 100644
--- a/test/setup.sh
+++ b/test/setup.sh
@@ -12,6 +12,7 @@ GIT_AUTH="$TOPLEVEL/git-interface/git-auth.py"
GIT_SERVE="$TOPLEVEL/git-interface/git-serve.py"
GIT_UPDATE="$TOPLEVEL/git-interface/git-update.py"
MKPKGLISTS="$TOPLEVEL/scripts/mkpkglists.py"
+TUVOTEREMINDER="$TOPLEVEL/scripts/tuvotereminder.py"
# Create the configuration file and a dummy notification script.
cat >config <<-EOF
@@ -47,8 +48,9 @@ packagesfile = packages.gz
pkgbasefile = pkgbase.gz
EOF
-cat >notify.sh <<-EOF
+cat >notify.sh <<-\EOF
#!/bin/sh
+echo $* >>notify.out
EOF
chmod +x notify.sh
diff --git a/test/t2200-tuvotereminder.sh b/test/t2200-tuvotereminder.sh
new file mode 100755
index 0000000..438c0c3
--- /dev/null
+++ b/test/t2200-tuvotereminder.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+test_description='tuvotereminder tests'
+
+. ./setup.sh
+
+test_expect_success 'Test Trusted User vote reminders.' '
+ now=$(date -d now +%s) &&
+ tomorrow=$(date -d tomorrow +%s) &&
+ threedays=$(date -d "3 days" +%s) &&
+ cat <<-EOD | sqlite3 aur.db &&
+ INSERT INTO TU_VoteInfo (ID, Agenda, User, Submitted, End, Quorum, SubmitterID) VALUES (1, "Lorem ipsum.", "user", 0, $now, 0.00, 2);
+ INSERT INTO TU_VoteInfo (ID, Agenda, User, Submitted, End, Quorum, SubmitterID) VALUES (2, "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);
+ EOD
+ >notify.out &&
+ "$TUVOTEREMINDER" &&
+ cat <<-EOD >expected &&
+ tu-vote-reminder 2
+ tu-vote-reminder 3
+ EOD
+ test_cmp notify.out expected
+'
+
+test_done