From bccf84211be4abda3c96ded43f03b597081fecb1 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 7 Aug 2010 21:21:08 +0200 Subject: add test for db-remove --- test/lib/common.inc | 13 +++------ test/runTest | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/lib/common.inc b/test/lib/common.inc index 5abe2ed..4052aa1 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -1,4 +1,4 @@ -pkgdir="$(dirname $0)/packages" +pkgdir="${curdir}/packages" oneTimeSetUp() { local p @@ -57,20 +57,13 @@ eot } tearDown() { + echo -n 'Cleaning up...' rm -rf "${TMP}" rm -f "${curdir}/../config.local" + echo 'done' echo } -testPackages() { - local p - for p in "${pkgdir}"/*; do - pushd $p >/dev/null - namcap *.pkg.tar.* || fail 'namcap failed' - popd >/dev/null - done -} - releasePackage() { local repo=$1 local pkgbase=$2 diff --git a/test/runTest b/test/runTest index 1d54ea4..258a181 100755 --- a/test/runTest +++ b/test/runTest @@ -3,6 +3,23 @@ curdir=$(readlink -e $(dirname $0)) . "${curdir}/lib/common.inc" +# +# self test +# + +testPackages() { + local p + for p in "${pkgdir}"/*; do + pushd $p >/dev/null + namcap *.pkg.tar.* || fail 'namcap failed' + popd >/dev/null + done +} + + +# +# db-update +# testAddSimplePackages() { local arches=('i686' 'x86_64') @@ -63,4 +80,65 @@ testAddSplitPackages() { } +# +# db-remove +# + +testRemovePackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b') + local pkgbase + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + releasePackage extra ${pkgbase} ${arch} + done + done + + ../db-update extra + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + ../db-remove ${pkgbase} extra ${arch} + 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" + done + done +} + +testRemoveAnyPackages() { + local arches=('i686' 'x86_64') + local pkgs=('pkg-any-a' 'pkg-any-b') + local pkgbase + + for pkgbase in ${pkgs[@]}; do + releasePackage extra ${pkgbase} any + done + + ../db-update extra + + for pkgbase in ${pkgs[@]}; do + ../db-remove ${pkgbase} extra any + 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 + 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" + done +} + + . "${curdir}/lib/shunit2" -- cgit v1.2.3-54-g00ecf