]> pd.if.org Git - zpackage/blob - t/hash.t
add -p option to update to pass through to syncfs
[zpackage] / t / hash.t
1 #!/bin/sh
2
3 # test addfile
4
5 . tap.sh
6
7 vtest() {
8         res=$(zpm-hash "$1" "$2")
9         okstreq "$res" "$2" "$3"
10 }
11
12 plan 7
13
14 printf '' > hash.test
15 vtest hash.test e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 "empty file"
16 printf 'foo\n' > hash.test
17 vtest hash.test b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c "one line file"
18
19 rm hash.test
20
21 res=$(printf 'foo\n' | zpm-hash)
22 okstreq $res b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c "foo"
23
24 res=$(printf 'foo\n' | zpm-hash -)
25 okstreq $res b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c "foo stdin"
26
27 stest() {
28         res=$(printf '%s' $1 | zpm-hash -)
29         okstreq "$res" "$2" "${1:-empty string}"
30 }
31
32 stest abc ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
33 stest '' e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
34 stest 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' '248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1'
35
36 finish