X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=t%2Fpathmod.t;fp=t%2Fpathmod.t;h=47575e6f6361bac2fcf99df7096fe1317686534a;hb=be0c3329afef13f1b9e888e48790bc65bee7439e;hp=0000000000000000000000000000000000000000;hpb=28ff0abf216c03268efedb6d43eb2d3e04c3e8aa;p=zpackage diff --git a/t/pathmod.t b/t/pathmod.t new file mode 100755 index 0000000..47575e6 --- /dev/null +++ b/t/pathmod.t @@ -0,0 +1,85 @@ +#!/bin/sh + +# vim: syn=sh + +# test addfile + +. tap.sh + +plan 13 + +owner=$(id -un) +group=$(id -gn) + +newpkg() { + pkgid=$1 + tryrun zpm init $pkgid.zpm + if [ $? -eq 0 ]; then + tryrun zpm newpackage -f $pkgid.zpm $pkgid + if [ $? -eq 0 ]; then + shift + tryrun zpm add -u $owner -g $group -f $pkgid.zpm $pkgid "$@" + return $? + else + skip 1 not adding files init failed + return 1 + fi + else + skip 2 "unable to init $pkgid.zpm" + fi + return 0 +} + +oktest() { + test $1 $2 + okexit test $1 $2 +} + +oknottest() { + test $1 $2 + failsok test $1 $2 fails +} + +require rm -rf tmp +require mkdir tmp +cd tmp || bailout + +# set up a new package + +pkgid=pathmod-1.0-1 +newpkg $pkgid /bin/true +okexit setup package $pkgid +PF=$pkgid.zpm + +username=$(zpm pathmod -f $PF $pkgid /bin/true username) +okstreq "$username" "$owner" 'default owned by current user' +zpm pathmod -f $PF $pkgid /bin/true username=root +username=$(zpm pathmod -f $PF $pkgid /bin/true username) +okstreq "$username" root 'set username to root' +has=$(zpm contents -q -f $PF $pkgid : /bin/true) +okstreq "$has" /bin/true 'package has /bin/true' + +zpm packagehash -qs -f $PF $pkgid +hash=$(zpm packagehash -f $PF $pkgid) +if [ -n "$hash" ]; then + pass 'packagehash set' + diag $hash +else + fail 'packagehash set' +fi + +zpm pathmod -f $PF $pkgid /bin/true delete +zpm contents -q -f $PF $pkgid : /bin/true +has=$(zpm contents -q -f $PF $pkgid : /bin/true) +okstreq "$has" '' '/bin/true deleted' + +hash=$(zpm packagehash -e -f $PF $pkgid) +if [ -z "$hash" ]; then + pass 'packagehash cleared' +else + fail 'packagehash cleared' + diag $hash +fi + +cd .. || bailout +require rm -rf tmp