Skip to content

Commit 10b55ce

Browse files
committed
Move tests for "if" pseudo-location.
1 parent c3372c6 commit 10b55ce

File tree

3 files changed

+77
-109
lines changed

3 files changed

+77
-109
lines changed

t/loc-if.t

Lines changed: 0 additions & 109 deletions
This file was deleted.

t/output.t

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,3 +391,29 @@ Content-Type: text/plain
391391
--- response_body eval
392392
"\0\3"
393393
--- timeout: 10
394+
395+
396+
397+
=== TEST 18: value - "if" pseudo-location
398+
--- http_config eval: $::http_config
399+
--- config
400+
default_type text/plain;
401+
402+
location /postgres {
403+
if ($arg_foo) {
404+
postgres_pass database;
405+
postgres_query "select * from cats order by id";
406+
postgres_output value 0 0;
407+
break;
408+
}
409+
410+
return 404;
411+
}
412+
--- request
413+
GET /postgres?foo=1
414+
--- error_code: 200
415+
--- response_headers
416+
Content-Type: text/plain
417+
--- response_body chomp
418+
2
419+
--- timeout: 10

t/sanity.t

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,54 @@ Content-Type: application/x-resty-dbd-stream
223223
--- response_body eval
224224
""
225225
--- timeout: 10
226+
227+
228+
229+
=== TEST 7: "if" pseudo-location
230+
--- http_config eval: $::http_config
231+
--- config
232+
location /postgres {
233+
if ($arg_foo) {
234+
postgres_pass database;
235+
postgres_query "select * from cats";
236+
break;
237+
}
238+
239+
return 404;
240+
}
241+
--- request
242+
GET /postgres?foo=1
243+
--- error_code: 200
244+
--- response_headers
245+
Content-Type: application/x-resty-dbd-stream
246+
--- response_body eval
247+
"\x{00}". # endian
248+
"\x{03}\x{00}\x{00}\x{00}". # format version 0.0.3
249+
"\x{00}". # result type
250+
"\x{00}\x{00}". # std errcode
251+
"\x{02}\x{00}". # driver errcode
252+
"\x{00}\x{00}". # driver errstr len
253+
"". # driver errstr data
254+
"\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}". # rows affected
255+
"\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}\x{00}". # insert id
256+
"\x{02}\x{00}". # col count
257+
"\x{09}\x{00}". # std col type (integer/int)
258+
"\x{17}\x{00}". # driver col type
259+
"\x{02}\x{00}". # col name len
260+
"id". # col name data
261+
"\x{06}\x{80}". # std col type (varchar/str)
262+
"\x{19}\x{00}". # driver col type
263+
"\x{04}\x{00}". # col name len
264+
"name". # col name data
265+
"\x{01}". # valid row flag
266+
"\x{01}\x{00}\x{00}\x{00}". # field len
267+
"2". # field data
268+
"\x{ff}\x{ff}\x{ff}\x{ff}". # field len
269+
"". # field data
270+
"\x{01}". # valid row flag
271+
"\x{01}\x{00}\x{00}\x{00}". # field len
272+
"3". # field data
273+
"\x{03}\x{00}\x{00}\x{00}". # field len
274+
"bob". # field data
275+
"\x{00}" # row list terminator
276+
--- timeout: 10

0 commit comments

Comments
 (0)