]> pd.if.org Git - zpackage/blob - t/schema.t
add -p option to update to pass through to syncfs
[zpackage] / t / schema.t
1 #!/bin/sh
2
3 . tap.sh
4
5 plan 7
6
7 require rm -rf tmp
8 require mkdir tmp
9
10 PF=test.db
11
12 zpm-shell tmp/$PF < db.sql
13
14 okexit direct schema load || bailout 'cannot load schema'
15
16 cd tmp
17
18 { cat<<-EOS
19 pragma foreign_keys = off;
20 insert into packagefiles
21 (package,version,release,path,mode,username,groupname,hash)
22 values
23 ('foo','1',1,'/nopath','0644','root','root','fakehash')
24 EOS
25 } | zpm-shell $PF 2>/dev/null
26
27 okexit basic packagefile insert
28
29 { cat<<-EOS
30 pragma foreign_keys = off;
31 insert into packagefiles
32 (package,version,release,path,mode,username,groupname,hash)
33 values
34 ('foo','1',1,'/nopath','0644','root','root',NULL)
35 EOS
36 } | zpm-shell $PF 2>/dev/null
37
38 failsok regular with null hash rejected
39
40 { cat<<-EOS
41 pragma foreign_keys = off;
42 insert into packagefiles
43 (package,version,release,path,mode,username,groupname,hash)
44 values
45 ('foo','1',1,'/nopath','0644','root',NULL,'fakehash')
46 EOS
47 } | zpm-shell $PF 2>/dev/null
48
49 failsok null groupname rejected
50
51 #zpm-shell $PF '.tables'
52
53 { cat<<-EOS
54 pragma foreign_keys = off;
55 insert into packagefiles
56 (package,version,release,path,mode,username,groupname,hash)
57 values
58 ('foo','1',1,'/nopath','0644',NULL,'root','fakehash')
59 EOS
60 } | zpm-shell $PF 2>/dev/null
61
62 failsok null username rejected
63
64 # check the library logic
65
66 fakepkg() {
67 zpm-shell $PF "insert into packages (package,version,release,status)
68  values ('$1','$2',1,NULL)"
69 }
70
71 fakelib() {
72         hash="hv.$3.so.$4"
73         soname="lib$3.so.$4"
74         path="/lib/$soname"
75         hash="$path"
76 zpm-shell $PF "insert into packagefiles (package,version,release,path,hash)
77  values ('$1','$2',1,'$path','$hash');"
78 zpm-shell $PF "insert into elflibraries (file,soname)
79  values ('$hash','$soname');"
80         if [ -n "$5" ]; then
81                 dep="lib$5.so.$6"
82                 zpm-shell $PF "insert into elfneeded (file,needed)
83                 values ('$hash','$dep');"
84         fi
85 }
86
87 fakeprg() {
88         hash="hv.$2.$3"
89         path="/bin/$3 ($2)"
90         hash="$path"
91 zpm-shell $PF "insert into packagefiles (package,version,release,path,hash)
92  values ('$1','$2',1,'$path','$hash');"
93         if [ -n "$4" ]; then
94                 dep="lib$4.so.$5"
95                 zpm-shell $PF "insert into elfneeded (file,needed)
96                 values ('$hash','$dep');"
97         fi
98 }
99
100 exit 0
101 fakepkg foo 1.0 libfoo 1
102 fakepkg foo 2.0 libfoo 2
103 fakepkg hw 1.0
104 fakepkg hw 2.0
105 fakepkg bar 1.0
106 fakepkg bar 2.0
107 fakelib foo 1.0 foo 1 bar 1
108 fakelib foo 2.0 foo 2 bar 1
109 fakelib bar 1.0 bar 1
110 fakelib bar 2.0 bar 2
111 fakeprg hw 1.0 hw foo 1
112 fakeprg hw 2.0 hw foo 1
113
114 echo needed
115 zpm-shell $PF 'select * from elfneeded'
116 echo libs
117 zpm-shell $PF 'select * from elflibraries'
118
119 rm -f $PF
120 exit 0