]> pd.if.org Git - zpackage/commitdiff
add test program for zpm-addfile
authorNathan Wagner <nw@hydaspes.if.org>
Sun, 18 Sep 2016 07:20:25 +0000 (07:20 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sun, 18 Sep 2016 07:20:25 +0000 (07:20 +0000)
t/addfile [new file with mode: 0644]

diff --git a/t/addfile b/t/addfile
new file mode 100644 (file)
index 0000000..490ea96
--- /dev/null
+++ b/t/addfile
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+# test addfile
+
+tn=0
+planned=0
+
+okexit() {
+       if [ $? -ne 0 ]; then
+               printf 'not ';
+       fi
+       tn=$((tn + 1))
+       printf 'ok %d - %s\n' $tn "$*"
+}
+
+failsok() {
+       if [ $? -eq 0 ]; then
+               printf 'not ';
+       fi
+       tn=$((tn + 1))
+       printf 'ok %d - %s\n' $tn "$*"
+}
+
+exitwith() {
+       if [ $? -ne $1 ]; then
+               printf 'not ';
+       fi
+       shift
+       tn=$((tn + 1))
+       printf 'ok %d - %s\n' $tn "$*"
+}
+
+okstreq() {
+       note=
+       if [ "$1" != "$2" ]; then
+               printf 'not ';
+               note=$(printf '# got "%s" expected "%s"' "$1" "$2")
+       fi
+
+       shift;shift;
+       tn=$((tn + 1))
+       printf 'ok %d - %s\n' $tn "$*"
+       if [ "$note" != "" ]; then
+               printf '%s\n' "$note"
+       fi
+}
+
+plan() {
+       planned=$1
+       printf '1..%d\n' $planned
+}
+
+finish() {
+       if [ $planned -eq 0 ]; then
+               printf '1..%d\n' $tn
+       fi
+}
+
+plan 4
+
+PF=test.db
+
+rm -f $PF test.empty
+touch test.empty
+
+hash=$(../zpm-addfile $PF test.empty) >> test.out 2>&1
+okexit add empty file content
+okstreq $hash e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 hash contents
+
+appid=$(sqlite3 test.db 'pragma application_id')
+okstreq $appid 1515209794 application id set
+
+userv=$(sqlite3 test.db 'pragma user_version')
+okstreq $userv 1 db version set
+
+finish
+
+rm -f $PF test.empty