testcases for value return
[exim.git] / test / scripts / 2620-Postgresql / 2620
CommitLineData
de1294ea 1# pgsql lookups
ff059213
JH
2# The pgsql-devel (or equivalent) package will be need for Exim to build, and
3# the postgresql-server (or equivalent) package for this test to run.
de1294ea
JH
4#
5# first, populate a DB to test against
6sudo rm -fr DIR/pgsql
f63e7252 7echo Starting DB server
de1294ea 8perl
6481e125 9system 'DIR/bin.sys/initdb -D DIR/pgsql/data';
de1294ea 10****
2b665c13 11sudo rm test-stdout
de1294ea 12background
6481e125 13DIR/bin.sys/postgres -D DIR/pgsql/data -p PORT_N -k DIR/pgsql
de1294ea 14****
2b665c13 15sleep 1
f63e7252 16echo Waiting for DB server
de1294ea 17perl
f63e7252 18system 'DIR/bin.sys/pg_ctl -w -D DIR/pgsql/data status';
de1294ea
JH
19system 'createdb -h localhost -p PORT_N test';
20system 'psql -h localhost -p PORT_N -d test \
2b665c13
JH
21 -c "CREATE TABLE them ( name text, id text ); \
22 INSERT INTO them VALUES ( \'Philip Hazel\', \'ph10\' ); \
23 INSERT INTO them VALUES ( \'Aristotle\', \'aaaa\' ); \
24 INSERT INTO them VALUES ( \'\', \'nothing\' ); \
25 INSERT INTO them VALUES ( \'\"stquot\', \'quote2\' ); \
26 INSERT INTO them VALUES ( \'before\' || CHR(13) || CHR(10) || \'after\', \'newline\' ); \
27 INSERT INTO them VALUES ( \'x\' || CHR(9) || \'x\', \'tab\' ); \
28 INSERT INTO them VALUES ( CHR(39) || \'stquot\', \'quote1\' );" \
de1294ea
JH
29 ';
30****
f63e7252 31echo Populated DB server
de1294ea
JH
32#
33# now, the tests
59371ea7
PH
34exim -d-all+lookup -be
35${lookup pgsql {select name from them where id='ph10';}}
36${lookup pgsql {select name from them where id='ph10';}}
37${lookup pgsql {select name from them where id='xxxx';}}
38${lookup pgsql {select name from them where id='nothing';}}
39${lookup pgsql {select id,name from them where id='nothing';}}
40${lookup pgsql {delete from them where id='nonexist';}}
41${lookup pgsql {select * from them where id='quote2';}}
42${lookup pgsql {select * from them where id='newline';}}
43${lookup pgsql {select * from them where id='tab';}}
5547e2c5 44${lookup pgsql {select * from them where name='${quote_pgsql:'stquot}';}}
b7670459 45${lookup pgsql {servers=x:localhost; select name from them where id='ph10';}}
de1294ea
JH
46${lookup pgsql {servers=localhost::PORT_N:x; select name from them where id='ph10';}}
47${lookup pgsql {servers=localhost::PORT_N/test/CALLER/:x; select name from them where id='ph10';}}
48${lookup pgsql {servers=(DIR/pgsql/.s.PGSQL.PORT_N)/test/CALLER/:x; select name from them where id='ph10';}}
bbfb5dcd
JH
49x
50${lookup pgsql {SELECT name FROM them WHERE id IN ('ph10', 'aaaa');}}
51${lookup pgsql {SELECT * FROM them WHERE id IN ('ph10', 'aaaa');}}
ba0e37b1 52${lookup pgsql {delete from them where id='aaaa'}}
59371ea7
PH
53****
54exim -d -bh 10.0.0.0
55mail from:<a@b>
56rcpt to:<c@d>
57rcpt to:<c@d>
58quit
59****
60exim -odi -d CALLER
61Test message
62.
63****
de1294ea
JH
64exim -DSERVERS=\(DIR/pgsql/.s.PGSQL.PORT_N\)/test/CALLER/ -d-all+lookup -be
65${lookup pgsql {select name from them where id='ph10';}}
66****
67#
68perl
f63e7252 69system 'DIR/bin.sys/pg_ctl stop -D DIR/pgsql/data -m immediate';
59371ea7 70****
f63e7252 71sleep 2
de1294ea
JH
72killdaemon
73sudo rm -fr DIR/pgsql