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