Skip to content

Commit a08e95c

Browse files
committed
added pg database initialization tests to 000_init.t.
1 parent 98beb5c commit a08e95c

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,5 @@ all.sh
6868
build9
6969
t/servroot/
7070
buildroot/
71+
build10
72+
go

t/000_init.t

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ repeat_each(1);
88
plan tests => repeat_each() * blocks();
99

1010
$ENV{TEST_NGINX_MYSQL_PORT} ||= 3306;
11+
$ENV{TEST_NGINX_POSTGRESQL_PORT} ||= 5432;
1112

1213
our $http_config = <<'_EOC_';
1314
upstream database {
1415
drizzle_server 127.0.0.1:$TEST_NGINX_MYSQL_PORT protocol=mysql
1516
dbname=ngx_test user=ngx_test password=ngx_test;
1617
}
18+
19+
upstream pg {
20+
postgres_server 127.0.0.1:$TEST_NGINX_POSTGRESQL_PORT
21+
dbname=ngx_test user=ngx_test password=ngx_test;
22+
}
23+
1724
_EOC_
1825

1926
worker_connections(128);
@@ -77,3 +84,60 @@ GET /init
7784
GET /init
7885
--- error_code: 200
7986
--- timeout: 10
87+
88+
89+
90+
=== TEST 5: cats - drop table - pg
91+
--- http_config eval: $::http_config
92+
--- config
93+
location = /init {
94+
postgres_pass pg;
95+
postgres_query "DROP TABLE IF EXISTS cats";
96+
}
97+
--- request
98+
GET /init
99+
--- error_code: 200
100+
--- timeout: 10
101+
102+
103+
104+
=== TEST 6: cats - create table - pg
105+
--- http_config eval: $::http_config
106+
--- config
107+
location = /init {
108+
postgres_pass pg;
109+
postgres_query "CREATE TABLE cats (id integer, name text)";
110+
}
111+
--- request
112+
GET /init
113+
--- error_code: 200
114+
--- timeout: 10
115+
116+
117+
118+
=== TEST 7: cats - insert value - pg
119+
--- http_config eval: $::http_config
120+
--- config
121+
location = /init {
122+
postgres_pass pg;
123+
postgres_query "INSERT INTO cats (id) VALUES (2)";
124+
}
125+
--- request
126+
GET /init
127+
--- error_code: 200
128+
--- timeout: 10
129+
130+
131+
132+
=== TEST 8: cats - insert value - pg
133+
--- http_config eval: $::http_config
134+
--- config
135+
location = /init {
136+
postgres_pass pg;
137+
postgres_query "INSERT INTO cats (id, name) VALUES (3, 'bob')";
138+
}
139+
--- request
140+
GET /init
141+
--- error_code: 200
142+
--- timeout: 10
143+

0 commit comments

Comments
 (0)