poldek: poldek/tests/sh/05-clean-repo (NEW), poldek/tests/sh/02-up...

mis mis at pld-linux.org
Mon Jun 25 00:48:57 CEST 2007


Author: mis                          Date: Sun Jun 24 22:48:57 2007 GMT
Module: poldek                        Tag: HEAD
---- Log message:
- more tests

---- Files affected:
poldek/poldek/tests/sh:
   05-clean-repo (NONE -> 1.1)  (NEW), 02-up-repo (1.2 -> 1.3) 
poldek/poldek/tests/sh/lib:
   repo-setup (1.3 -> 1.4) , vftest.sh (1.3 -> 1.4) 

---- Diffs:

================================================================
Index: poldek/poldek/tests/sh/05-clean-repo
diff -u /dev/null poldek/poldek/tests/sh/05-clean-repo:1.1
--- /dev/null	Mon Jun 25 00:48:57 2007
+++ poldek/poldek/tests/sh/05-clean-repo	Mon Jun 25 00:48:52 2007
@@ -0,0 +1,62 @@
+#!/bin/sh
+# $Id$
+
+. ./sh/lib/setup
+. ./sh/lib/repo-setup
+
+mkidx() {
+   $POLDEK_NOCONF -s $REPO --mkidx --mt pndir || fail "mkidx failed"
+}
+
+up() {
+   poldek_up -Oautoupa=n --up || fail "up failed"
+}
+
+testCleanLocalCache() 
+{
+    POLDEK_TESTING_DENIED_FILES="packages.ndir.diff.toc"
+
+    msgn "Creating repo"
+    indexfile="$REPO/packages.ndir.gz"
+    mkidx
+    die_if_empty_index $indexfile
+    
+    msgn "up"
+    up
+
+    msgn "Fetching package"
+    package=$(poldek_up --skip-installed -q --cmd 'ls -q | !head -1')
+    [ -n "$package" ] || fail "no available packages??"
+
+    msg "  - $package"
+    poldek_up --skip-installed --cmd "get -d $CACHEDIR $package"
+    downloaded=$(find $CACHEDIR -name $package\*.rpm | wc -l)
+    assertEquals "$package not downloaded?" "1" $downloaded
+
+    # no simply way to fetch packages to local repo cache1
+    index=$(find $CACHEDIR -name packages.ndir.gz)
+    mv -f $CACHEDIR/$package*.rpm $(dirname $index)
+    #find $CACHEDIR
+
+    msgn "clean"
+    poldek_up --clean 
+    files=$(find $CACHEDIR -type f | grep -vE '\.rpm$')
+    n=$(find $CACHEDIR -type f | grep -vE '\.rpm$' | wc -l)
+    assertEquals "cachedir still contains non rpm files ($files)" "0" "$n"
+    
+    n=$(find $CACHEDIR | grep "$package" | wc -l) # no -f its 
+    assertEquals "cachedir: missing $package" "1" "$n"
+    
+    msgn "up"
+    up
+
+    msgn "cleana aka clean-whole"
+    poldek_up --cleana
+    n=$(find $CACHEDIR -type f | wc -l)
+    assertEquals "cachedir still contains files" "0" "$n"
+    
+    n=$(find $CACHEDIR -type l | wc -l)
+    assertEquals "cachedir still contains files" "0" "$n"
+}
+
+. ./sh/lib/shunit2
\ No newline at end of file

================================================================
Index: poldek/poldek/tests/sh/02-up-repo
diff -u poldek/poldek/tests/sh/02-up-repo:1.2 poldek/poldek/tests/sh/02-up-repo:1.3
--- poldek/poldek/tests/sh/02-up-repo:1.2	Sun Jun 24 13:31:14 2007
+++ poldek/poldek/tests/sh/02-up-repo	Mon Jun 25 00:48:52 2007
@@ -67,7 +67,10 @@
     msg "\n## up"
 
     POLDEK_TESTING_DENIED_FILES="packages.ndir.diff.toc"
-    $POLDEK_UP -Oautoupa=yes -Osource="test,type=pndir $REPOURL" --up || fail "up failed"
+    $POLDEK_UP -Oautoupa=n -Osource="test,type=pndir $REPOURL" --up >/dev/null
+    [ $? -eq 0 ] && fail "up ok" # should fail
+
+    $POLDEK_UP -Oautoupa=y -Osource="test,type=pndir $REPOURL" --up || fail "up(a) failed"
     POLDEK_TESTING_DENIED_FILES=""
 
     # upa
@@ -80,7 +83,9 @@
     POLDEK_TESTING_DENIED_FILES="packages.ndir.gz"
     $POLDEK_UP -Oautoupa=n -Osource="test,type=pndir $REPOURL" --up || fail "up failed"
 
-    POLDEK_TESTING_DENIED_FILES=""
+    POLDEK_TESTING_DENIED_FILES=".gz" # should be up to date
+    $POLDEK_UP -Oautoupa=n -Osource="test,type=pndir $REPOURL" --up || fail "up failed"
+    $POLDEK_UP -Oautoupa=n -Osource="test,type=pndir $REPOURL" --upa || fail "up failed"
 }
 
 . ./sh/lib/shunit2

================================================================
Index: poldek/poldek/tests/sh/lib/repo-setup
diff -u poldek/poldek/tests/sh/lib/repo-setup:1.3 poldek/poldek/tests/sh/lib/repo-setup:1.4
--- poldek/poldek/tests/sh/lib/repo-setup:1.3	Sun Jun 24 13:31:14 2007
+++ poldek/poldek/tests/sh/lib/repo-setup	Mon Jun 25 00:48:52 2007
@@ -12,9 +12,7 @@
 
 oneTimeSetUp() {
     [ ! -d "$PWD/sh/lib" ] && fail "$PWD is not a tests directory (missing sh/lib)"
-    POLDEK="$PWD/../cli/poldek $QUIET"
-    POLDEK_NOCONF="$POLDEK --noconf -Ovfile_retries=1"
-
+    
     SOURCE_REPO=${SOURCE_REPO:-"${PWD}/repo"}
     [ ! -d "$SOURCE_REPO" ] && fail "$SOURCE_REPO: no such directory"
 
@@ -25,9 +23,14 @@
 
     rm -rf $TMPDIR
     mkdir -p $TMPDIR
-
     [ ! -d $TMPDIR ] && fail "$TMPDIR: no such directory"
 
+
+    CACHEDIR="$TMPDIR/kesz"
+    rm -rf $CACHEDIR
+    mkdir -p $CACHEDIR
+    [ ! -d $CACHEDIR ] && fail "$CACHEDIR: no such directory"
+
     REPO="$TMPDIR/repo"
     REPOURL="test://$TMPDIR/repo/"
 
@@ -35,9 +38,16 @@
     [ ! -d $REPO ] && fail "mkdir $REPO failed?"
 
     PATH="$PATH:$PWD/sh/lib/"
-    POLDEK_UP="$POLDEK --conf ./sh/lib/vftest-fetch.conf --cachedir $TMPDIR"
+
+    POLDEK="$PWD/../cli/poldek $QUIET"
+    POLDEK_NOCONF="$POLDEK --noconf -Ovfile_retries=1 --cachedir $CACHEDIR"
+    POLDEK_UP="$POLDEK --conf ./sh/lib/vftest-fetch.conf --cachedir $CACHEDIR"
     cp $SOURCE_REPO/*.rpm $REPO || fail
     tearDown
+}
+
+poldek_up() {
+    $POLDEK_UP -Osource="test,type=pndir $REPOURL" $@
 }
 
 oneTimeTearDown() {

================================================================
Index: poldek/poldek/tests/sh/lib/vftest.sh
diff -u poldek/poldek/tests/sh/lib/vftest.sh:1.3 poldek/poldek/tests/sh/lib/vftest.sh:1.4
--- poldek/poldek/tests/sh/lib/vftest.sh:1.3	Sun Jun 24 13:31:14 2007
+++ poldek/poldek/tests/sh/lib/vftest.sh	Mon Jun 25 00:48:52 2007
@@ -26,6 +26,7 @@
     fi
 done
 
+#echo $src $dest
 # Symlink packages, copy other files
 if echo $src | grep -qE '.rpm$'; then
     ln -sf $src $dest
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/poldek/poldek/tests/sh/02-up-repo?r1=1.2&r2=1.3&f=u
    http://cvs.pld-linux.org/poldek/poldek/tests/sh/lib/repo-setup?r1=1.3&r2=1.4&f=u
    http://cvs.pld-linux.org/poldek/poldek/tests/sh/lib/vftest.sh?r1=1.3&r2=1.4&f=u



More information about the pld-cvs-commit mailing list