summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-08-07 23:48:03 +0200
committerPierre Schmitz <pierre@archlinux.de>2010-08-07 23:48:03 +0200
commit76ef37d1b1e03b0c517f8513b943474ea379738e (patch)
tree9692751d5dd379b4a472beba94193ceceb310875 /test
parentbccf84211be4abda3c96ded43f03b597081fecb1 (diff)
downloaddbscripts-76ef37d1b1e03b0c517f8513b943474ea379738e.tar.gz
dbscripts-76ef37d1b1e03b0c517f8513b943474ea379738e.tar.xz
Simplify tests and add tests for db-move
Diffstat (limited to 'test')
-rw-r--r--test/lib/common.inc38
-rwxr-xr-xtest/runTest86
2 files changed, 110 insertions, 14 deletions
diff --git a/test/lib/common.inc b/test/lib/common.inc
index 4052aa1..3ba715e 100644
--- a/test/lib/common.inc
+++ b/test/lib/common.inc
@@ -1,12 +1,14 @@
-pkgdir="${curdir}/packages"
+. "${curdir}/../db-functions"
oneTimeSetUp() {
local p
+ pkgdir="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)"
+ cp -r ${curdir}/packages/* "${pkgdir}"
echo -n 'Building packages...'
for p in "${pkgdir}"/*; do
pushd $p >/dev/null
linux32 makepkg -cf --config ${curdir}/lib/makepkg-i686.conf >/dev/null 2>&1 || exit 1
- linux64 makepkg -cf --config ${curdir}/lib/makepkg-x86_64.conf >/dev/null 2>&1 || exit 1
+ [ -f *-any.pkg.tar.* ] || linux64 makepkg -cf --config ${curdir}/lib/makepkg-x86_64.conf >/dev/null 2>&1 || exit 1
popd >/dev/null
done
echo 'done'
@@ -22,7 +24,7 @@ setUp() {
local pkg
[ -f "${curdir}/../config.local" ] && exit 1
- TMP="$(mktemp -d /tmp/$(basename $0).XXXXXXXXXX)"
+ TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)"
#echo "Using ${TMP}"
mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-{packages,community}-{copy,repo}}
@@ -82,7 +84,7 @@ checkAnyPackage() {
[ -f "${FTP_BASE}/packages/arch/any/${pkg}" ] || fail "packages/arch/any/${pkg} not found"
- for arch in any i686 x86_64; do
+ for arch in i686 x86_64; do
[ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink"
[ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/packages/arch/any/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to packages/arch/any/${pkg}"
done
@@ -103,4 +105,32 @@ checkPackage() {
[ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/packages/arch/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} does not link to packages/arch/${arch}/${pkg}"
bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}.db.tar.gz" -O | grep -q ${pkg} || fail "${pkg} not in ${repo}/os/${arch}/${repo}.db.tar.gz"
+
+ local pkgbase=$(getpkgbase "${FTP_BASE}/packages/arch/${arch}/${pkg}")
+ svn up -q "${TMP}/svn-packages-copy/${pkgbase}"
+ [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] || fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} does not exist"
+}
+
+checkRemovedPackage() {
+ local repo=$1
+ local pkgbase=$2
+ local arch=$3
+
+ bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}.db.tar.gz" -O | grep -q ${pkgbase} && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}.db.tar.gz"
+
+ svn up -q "${TMP}/svn-packages-copy/${pkgbase}"
+ [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] && fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} should not exist"
}
+
+checkRemovedAnyPackage() {
+ local repo=$1
+ local pkgbase=$2
+ local arch
+
+ for arch in i686 x86_64; do
+ bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}.db.tar.gz" -O | grep -q ${pkgbase} && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}.db.tar.gz"
+ done
+
+ svn up -q "${TMP}/svn-packages-copy/${pkgbase}"
+ [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] && fail "svn-packages-copy/${pkgbase}/repos/${repo}-any should not exist"
+} \ No newline at end of file
diff --git a/test/runTest b/test/runTest
index 258a181..c53b63c 100755
--- a/test/runTest
+++ b/test/runTest
@@ -103,20 +103,14 @@ testRemovePackages() {
done
done
- for arch in ${arches[@]}; do
- [ -z "$(bsdtar -tf "${FTP_BASE}/extra/os/${arch}/extra.db.tar.gz" -O)" ] || fail "extra/os/${arch}/${repo}.db.tar.gz should be empty"
- done
-
for pkgbase in ${pkgs[@]}; do
for arch in ${arches[@]}; do
- svn up -q "${TMP}/svn-packages-copy/${pkgbase}"
- [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/extra-${arch}" ] && fail "svn-packages-copy/${pkgbase}/repos/extra-${arch} should not exist"
+ checkRemovedPackage extra ${pkgbase} ${arch}
done
done
}
testRemoveAnyPackages() {
- local arches=('i686' 'x86_64')
local pkgs=('pkg-any-a' 'pkg-any-b')
local pkgbase
@@ -130,15 +124,87 @@ testRemoveAnyPackages() {
../db-remove ${pkgbase} extra any
done
+ for pkgbase in ${pkgs[@]}; do
+ checkRemovedAnyPackage extra ${pkgbase}
+ done
+}
+
+
+#
+# db-move
+#
+
+testMoveSimplePackages() {
+ local arches=('i686' 'x86_64')
+ local pkgs=('pkg-simple-a' 'pkg-simple-b')
+ local pkgbase
+
+ for pkgbase in ${pkgs[@]}; do
+ for arch in ${arches[@]}; do
+ releasePackage testing ${pkgbase} ${arch}
+ done
+ done
+
+ ../db-update testing
+
+ for arch in ${arches[@]}; do
+ ../db-move-draft pkg-simple-a testing extra ${arch}
+ done
+
for arch in ${arches[@]}; do
- [ -z "$(bsdtar -tf "${FTP_BASE}/extra/os/${arch}/extra.db.tar.gz" -O)" ] || fail "extra/os/${arch}/${repo}.db.tar.gz should be empty"
+ checkPackage extra pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch}
+ checkRemovedPackage testing pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch}
+
+ checkPackage testing pkg-simple-b-1-1-${arch}.pkg.tar.xz ${arch}
done
+}
+
+testMoveAnyPackages() {
+ local pkgs=('pkg-any-a' 'pkg-any-b')
+ local pkgbase
for pkgbase in ${pkgs[@]}; do
- svn up -q "${TMP}/svn-packages-copy/${pkgbase}"
- [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/extra-any" ] && fail "svn-packages-copy/${pkgbase}/repos/extra-any should not exist"
+ releasePackage testing ${pkgbase} any
done
+
+ ../db-update testing
+ ../db-move-draft pkg-any-a testing extra any
+
+ checkAnyPackage extra pkg-any-a-1-1-any.pkg.tar.xz
+ checkRemovedAnyPackage testing pkg-any-a
+ checkAnyPackage testing pkg-any-b-1-1-any.pkg.tar.xz
}
+testMoveSplitPackages() {
+ local arches=('i686' 'x86_64')
+ local pkgs=('pkg-split-a' 'pkg-split-b')
+ local pkg
+ local pkgbase
+
+ for pkgbase in ${pkgs[@]}; do
+ for arch in ${arches[@]}; do
+ releasePackage testing ${pkgbase} ${arch}
+ done
+ done
+
+ ../db-update testing
+
+ for arch in ${arches[@]}; do
+ ../db-move-draft pkg-split-a testing extra ${arch}
+ done
+
+ for arch in ${arches[@]}; do
+ for pkg in "${pkgdir}/pkg-split-a"/*-${arch}.pkg.tar.*; do
+ checkPackage extra $(basename ${pkg}) ${arch}
+ done
+ done
+ for arch in ${arches[@]}; do
+ for pkg in "${pkgdir}/pkg-split-b"/*-${arch}.pkg.tar.*; do
+ checkPackage testing $(basename ${pkg}) ${arch}
+ done
+ done
+
+ checkRemovedAnyPackage testing pkg-split-a
+}
. "${curdir}/lib/shunit2"