summaryrefslogtreecommitdiffstats
path: root/test/t1200-git-serve.sh
diff options
context:
space:
mode:
Diffstat (limited to 'test/t1200-git-serve.sh')
-rwxr-xr-xtest/t1200-git-serve.sh66
1 files changed, 66 insertions, 0 deletions
diff --git a/test/t1200-git-serve.sh b/test/t1200-git-serve.sh
index d422c480..f986b625 100755
--- a/test/t1200-git-serve.sh
+++ b/test/t1200-git-serve.sh
@@ -414,4 +414,70 @@ test_expect_success "Flag using a comment which is too short." '
test_cmp expected actual
'
+test_expect_success "Vote for a package base." '
+ SSH_ORIGINAL_COMMAND="vote foobar" AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ 3|1
+ EOF
+ echo "SELECT PackageBaseID, UsersID FROM PackageVotes;" | \
+ sqlite3 aur.db >actual &&
+ test_cmp expected actual &&
+ cat >expected <<-EOF &&
+ 1
+ EOF
+ echo "SELECT NumVotes FROM PackageBases WHERE Name = \"foobar\";" | \
+ sqlite3 aur.db >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success "Vote for a package base twice." '
+ SSH_ORIGINAL_COMMAND="vote foobar" AUR_USER=user AUR_PRIVILEGED=0 \
+ test_must_fail "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ 3|1
+ EOF
+ echo "SELECT PackageBaseID, UsersID FROM PackageVotes;" | \
+ sqlite3 aur.db >actual &&
+ test_cmp expected actual &&
+ cat >expected <<-EOF &&
+ 1
+ EOF
+ echo "SELECT NumVotes FROM PackageBases WHERE Name = \"foobar\";" | \
+ sqlite3 aur.db >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success "Remove vote from a package base." '
+ SSH_ORIGINAL_COMMAND="unvote foobar" AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ EOF
+ echo "SELECT PackageBaseID, UsersID FROM PackageVotes;" | \
+ sqlite3 aur.db >actual &&
+ test_cmp expected actual &&
+ cat >expected <<-EOF &&
+ 0
+ EOF
+ echo "SELECT NumVotes FROM PackageBases WHERE Name = \"foobar\";" | \
+ sqlite3 aur.db >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success "Try to remove the vote again." '
+ SSH_ORIGINAL_COMMAND="unvote foobar" AUR_USER=user AUR_PRIVILEGED=0 \
+ test_must_fail "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ EOF
+ echo "SELECT PackageBaseID, UsersID FROM PackageVotes;" | \
+ sqlite3 aur.db >actual &&
+ test_cmp expected actual &&
+ cat >expected <<-EOF &&
+ 0
+ EOF
+ echo "SELECT NumVotes FROM PackageBases WHERE Name = \"foobar\";" | \
+ sqlite3 aur.db >actual &&
+ test_cmp expected actual
+'
+
test_done