]> pd.if.org Git - zpackage/blob - t/addfile.t
fixup tests
[zpackage] / t / addfile.t
1 #!/bin/sh
2
3 # test addfile
4
5 tn=0
6 planned=0
7
8 shownote() {
9         if [ "$note" != "" ]; then
10                 printf '# %s\n' "$note"
11         fi
12 }
13
14 okexit() {
15         exitwith 0 "$*"
16 }
17
18 failsok() {
19         note=
20         if [ $? -eq 0 ]; then
21                 printf 'not ';
22                 note=$(printf '# got "%d" expected "%d"' "$1" "0")
23         fi
24         tn=$((tn + 1))
25         printf 'ok %d - %s\n' $tn "$*"
26         shownote
27 }
28
29 exitwith() {
30         note=
31         if [ $? -ne $1 ]; then
32                 printf 'not ';
33                 note=$(printf '# got "%d" expected "%d"' "$1" "$2")
34         fi
35         shift
36         tn=$((tn + 1))
37         printf 'ok %d - %s\n' $tn "$*"
38         shownote
39 }
40
41 okstreq() {
42         note=
43         if [ "$1" != "$2" ]; then
44                 printf 'not ';
45                 note=$(printf 'got "%s" expected "%s"' "$1" "$2")
46         fi
47
48         shift;shift;
49         tn=$((tn + 1))
50         printf 'ok %d - %s\n' $tn "$*"
51         shownote
52 }
53
54 plan() {
55         planned=$1
56         printf '1..%d\n' $planned
57 }
58
59 finish() {
60         if [ $planned -eq 0 ]; then
61                 printf '1..%d\n' $tn
62         fi
63 }
64
65 plan 4
66
67 PF=test.db
68
69 rm -f $PF test.empty
70 touch test.empty
71
72 hash=$(./zpm-addfile $PF test.empty 2>> test.out)
73 okexit add empty file content
74 okstreq $hash e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 hash contents
75
76 appid=$(sqlite3 test.db 'pragma application_id')
77 okstreq $appid 1515209794 application id set
78
79 userv=$(sqlite3 test.db 'pragma user_version')
80 okstreq $userv 1 db version set
81
82 finish
83
84 #rm -f $PF test.empty