mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix: restore command, remove premature creation of pkgbase
We're currently creating a "PackageBases" when the "restore" command is executed. This is problematic for pkgbases that never existed before. In those cases it will create the record but fail in the update.py script. Thus it leaves an orphan "PackageBases" record in the DB (which does not have any related "Packages" record(s)) Navigating to such a packages /pkgbase/... URL will result in a crash since it is not foreseen to have "orphan" pkgbase records. We can safely remove the early creation of that record because it'll be taken care of in the update.py script that is being called We'll also fix some tests. Before it was executing a dummy script instead of "update.py" which might be a bit misleading since it did not check the real outcome of our "restore" action. Signed-off-by: moson-mo <mo-son@mailbox.org>
This commit is contained in:
parent
c6c81f0789
commit
143575c9de
3 changed files with 21 additions and 35 deletions
|
@ -137,14 +137,21 @@ test_expect_success "Try to push to someone else's repository as Trusted User."
|
|||
'
|
||||
|
||||
test_expect_success "Test restore." '
|
||||
# Delete from DB
|
||||
echo "DELETE FROM PackageBases WHERE Name = '"'"'foobar'"'"';" | \
|
||||
sqlite3 aur.db &&
|
||||
cat >expected <<-EOF &&
|
||||
user
|
||||
foobar
|
||||
EOF
|
||||
# "Create branch" as if it had been there
|
||||
new=$(git -C aur.git rev-parse HEAD^) &&
|
||||
echo $new > aur.git/.git/refs/heads/foobar &&
|
||||
# Restore deleted package
|
||||
SSH_ORIGINAL_COMMAND="restore foobar" AUR_USER=user AUR_PRIVILEGED=0 \
|
||||
cover "$GIT_SERVE" 2>&1 >actual
|
||||
cover "$GIT_SERVE" 2>&1 &&
|
||||
# We should find foobar with a new ID (3) in the DB after restore
|
||||
echo "SELECT ID FROM PackageBases WHERE Name = '"'"'foobar'"'"';" | \
|
||||
sqlite3 aur.db >actual &&
|
||||
cat >expected <<-EOF &&
|
||||
3
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
|
@ -174,7 +181,7 @@ test_expect_success "Adopt a package base as a regular user." '
|
|||
SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \
|
||||
cover "$GIT_SERVE" 2>&1 &&
|
||||
cat >expected <<-EOF &&
|
||||
*foobar
|
||||
foobar
|
||||
EOF
|
||||
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \
|
||||
cover "$GIT_SERVE" 2>&1 >actual &&
|
||||
|
@ -252,7 +259,7 @@ test_expect_success "Try to steal another user's package as a Trusted User." '
|
|||
cover "$GIT_SERVE" 2>&1 >actual &&
|
||||
test_cmp expected actual &&
|
||||
cat >expected <<-EOF &&
|
||||
*foobar
|
||||
foobar
|
||||
EOF
|
||||
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \
|
||||
cover "$GIT_SERVE" 2>&1 >actual &&
|
||||
|
@ -340,7 +347,7 @@ test_expect_success "Disown a package base and check (co-)maintainer list." '
|
|||
SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=user AUR_PRIVILEGED=0 \
|
||||
cover "$GIT_SERVE" 2>&1 &&
|
||||
cat >expected <<-EOF &&
|
||||
*foobar
|
||||
foobar
|
||||
EOF
|
||||
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user2 AUR_PRIVILEGED=0 \
|
||||
cover "$GIT_SERVE" 2>&1 >actual &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue