From: Nathan Wagner Date: Sun, 18 Sep 2016 07:20:25 +0000 (+0000) Subject: add test program for zpm-addfile X-Git-Tag: v0.1.6~188 X-Git-Url: https://pd.if.org/git/?p=zpackage;a=commitdiff_plain;h=a8aa09640ff6e65849a3e3298e0cd90a70e3c663 add test program for zpm-addfile --- diff --git a/t/addfile b/t/addfile new file mode 100644 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