]> pd.if.org Git - zpackage/blobdiff - t/pathmod.t
change package list terminator
[zpackage] / t / pathmod.t
diff --git a/t/pathmod.t b/t/pathmod.t
new file mode 100755 (executable)
index 0000000..47575e6
--- /dev/null
@@ -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