diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2017-01-23 09:10:04 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2017-01-23 09:10:29 +0100 |
commit | 0b09f200c50cd1e6737f6225b35f0af9d6f8bed8 (patch) | |
tree | f55d45b2979876471eef2b1728b6d7af94b17a5c /test | |
parent | 7ee2fddcca6ef924ccfd10e6de9a799a9eb1abeb (diff) | |
download | aur-0b09f200c50cd1e6737f6225b35f0af9d6f8bed8.tar.gz aur-0b09f200c50cd1e6737f6225b35f0af9d6f8bed8.tar.xz |
t1200: Add tests for vote/unvote
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'test')
-rwxr-xr-x | test/t1200-git-serve.sh | 66 |
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 |