[dbscripts] Expected behavior of db-remove?
diff mbox

Message ID 20180620235900.17405-1-lukeshu@lukeshu.com
State New
Headers show

Commit Message

Luke Shumaker June 20, 2018, 11:59 p.m. UTC
From: Luke Shumaker <lukeshu@parabola.nu>

Following is a test-case for db-remove demonstrating a case where I'm
not sure what the intended behavior is.  Note that the test-case is
identical to the existing "remove multiple packages" test-case, except
that 'pkg-single-arch' has been added to the pkgs=() array.  With
pacman 5.0, the test-case would have passed, but with pacman 5.1, the
test-case fails.

With the pacman 5.1 version of repo-remove, if any of the named
packages are not found, the entire transaction is aborted, and *no*
packages are removed.  With 5.0, it would have said "error", but still
proceeded to remove the other named packages.

So, in my test-case, because 'pkg-single-arch' is an x86_64 only
package (while the others are x86_64 and i686), db-remove succeeds on
x86_64, but fails to remove anything on i686 because pkg-single-arch
isn't present there.  Also note that despite saying "ERROR" and
failing to do anything, db-remove has a 0 exit-code; the test-case
failure doesn't happen until it calls checkRemovedPackage.

So, what's the desired behavior here?  Ignore packages that are
already missing from the repo, or abort if any of the named packages
aren't found?

---
 test/cases/db-remove.bats | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Patch
diff mbox

diff --git a/test/cases/db-remove.bats b/test/cases/db-remove.bats
index fe373bc..d72c9cf 100644
--- a/test/cases/db-remove.bats
+++ b/test/cases/db-remove.bats
@@ -44,6 +44,27 @@  load ../lib/common
 	done
 }
 
+@test "remove multiple packages - some single arch" {
+	local arches=('i686' 'x86_64')
+	local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b' 'pkg-simple-epoch' 'pkg-single-arch')
+	local pkgbase
+	local arch
+
+	for pkgbase in ${pkgs[@]}; do
+		releasePackage extra ${pkgbase}
+	done
+
+	db-update
+
+	for arch in ${arches[@]}; do
+		db-remove extra ${arch} ${pkgs[@]}
+	done
+
+	for pkgbase in ${pkgs[@]}; do
+		checkRemovedPackage extra ${pkgbase}
+	done
+}
+
 @test "remove any packages" {
 	local pkgs=('pkg-any-a' 'pkg-any-b')
 	local pkgbase