From 0b09f200c50cd1e6737f6225b35f0af9d6f8bed8 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 23 Jan 2017 09:10:04 +0100 Subject: t1200: Add tests for vote/unvote Signed-off-by: Lukas Fleischer --- test/t1200-git-serve.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'test') 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 -- cgit v1.2.3-24-g4f1b