X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=t%2Faddfile.t;h=65188bc8a1c10adcc2138af5d50ced8ece699f6a;hb=27f7fa2a8566beb45fc813fcd8ff3f1e7c738883;hp=fbfa70eb90bd70d39223d699d0659277c76b5e65;hpb=98344faf58c6ae59c9df9b46e4f0b0e49013846b;p=zpackage diff --git a/t/addfile.t b/t/addfile.t index fbfa70e..65188bc 100755 --- a/t/addfile.t +++ b/t/addfile.t @@ -2,83 +2,35 @@ # test addfile -tn=0 -planned=0 +. tap.sh -shownote() { - if [ "$note" != "" ]; then - printf '# %s\n' "$note" - fi -} - -okexit() { - exitwith 0 "$*" -} - -failsok() { - note= - if [ $? -eq 0 ]; then - printf 'not '; - note=$(printf '# got "%d" expected "%d"' "$1" "0") - fi - tn=$((tn + 1)) - printf 'ok %d - %s\n' $tn "$*" - shownote -} - -exitwith() { - note= - if [ $? -ne $1 ]; then - printf 'not '; - note=$(printf '# got "%d" expected "%d"' "$1" "$2") - fi - shift - tn=$((tn + 1)) - printf 'ok %d - %s\n' $tn "$*" - shownote -} - -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 "$*" - shownote -} - -plan() { - planned=$1 - printf '1..%d\n' $planned -} - -finish() { - if [ $planned -eq 0 ]; then - printf '1..%d\n' $tn - fi -} - -plan 4 +plan 7 PF=test.db rm -f $PF test.empty touch test.empty -hash=$(./zpm-addfile $PF test.empty 2>> test.out) -okexit add empty file content -okstreq $hash e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 hash contents +zpm init $PF +okexit create addfile test db +hash=$(zpm addfile $PF test.empty 2>> test.out) +okexit add empty file content +okstreq "$hash" 0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8 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 +mkdir test.dir +zpm-addfile $PF test.dir 2>>test.out +failsok fail to add directory +rmdir test.dir + +zpm-addfile $PF /dev/null 2>>test.out +failsok fail to device file + finish -#rm -f $PF test.empty +rm -f $PF test.empty