X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=t%2Fextract.t;h=203cc3841605fe13cac0a3b024714722c4210346;hb=2ac486ab18adbbb84563eafc0d67fa8da6ca7822;hp=b631006cc61702b3c6bbd93a6255cc100ffce1e2;hpb=2e690698fef46656959d76b7d69b7162b734a96d;p=zpackage diff --git a/t/extract.t b/t/extract.t index b631006..203cc38 100755 --- a/t/extract.t +++ b/t/extract.t @@ -1,88 +1,34 @@ #!/bin/sh -# test addfile +. tap.sh -tn=0 -planned=0 - -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 6 PF=test.db rm -f $PF test.foo echo foo > test.foo -hash=$(./zpm-addfile $PF test.foo 2>> test.out) +zpm init test.db +okexit create extract test db + +hash=$(zpm-addfile $PF test.foo 2>> test.out) save=$? okexit add foo file content -okstreq $hash b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c foo hash contents +okstreq "$hash" 20590a52c4f00588c500328b16d466c982a26fabaa5fa4dcc83052dd0a84f233 foo hash contents rm -f foo -./zpm-extract $PF $hash foo -okexit extract foo file content +zpm-extract -f $PF $hash test.foo2 +okexit extract foo file content -sha=$(sha256sum foo) +sha=$(zpm-hash test.foo2) okstreq $hash $sha extracted hash matches +sha=$(zpm-extract -f $PF $hash - | zpm-hash) +okstreq $hash $sha stdout extract hash matches + finish -#rm -f $PF test.empty +rm -f test.*