From a8aa09640ff6e65849a3e3298e0cd90a70e3c663 Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Sun, 18 Sep 2016 07:20:25 +0000 Subject: [PATCH] add test program for zpm-addfile --- t/addfile | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 t/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 -- 2.40.0