summaryrefslogtreecommitdiff
path: root/ngx_postgres-1.0/t/eval.t
blob: c87761daf5fb15a28e15d29b0d96d42cd6359294 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# vi:filetype=perl

use lib 'lib';
use Test::Nginx::Socket;

repeat_each(2);

plan tests => repeat_each() * (blocks() * 3);

$ENV{TEST_NGINX_POSTGRESQL_HOST} ||= '127.0.0.1';
$ENV{TEST_NGINX_POSTGRESQL_PORT} ||= 5432;

our $http_config = <<'_EOC_';
    upstream database {
        postgres_server  $TEST_NGINX_POSTGRESQL_HOST:$TEST_NGINX_POSTGRESQL_PORT
                         dbname=ngx_test user=ngx_test password=ngx_test;
    }
_EOC_

run_tests();

__DATA__

=== TEST 1: sanity
--- http_config eval: $::http_config
--- config
    location /eval {
        eval_subrequest_in_memory  off;

        eval $backend {
            postgres_pass    database;
            postgres_query   "select '$scheme://127.0.0.1:$server_port/echo'";
            postgres_output  value;
        }

        proxy_pass $backend;
    }

    location /echo {
        echo -n  "it works!";
    }
--- request
GET /eval
--- error_code: 200
--- response_headers
Content-Type: text/plain
--- response_body chomp
it works!
--- timeout: 10
--- skip_nginx: 3: < 0.8.25



=== TEST 2: sanity (simple case)
--- http_config eval: $::http_config
--- config
    location /eval {
        eval_subrequest_in_memory  off;

        eval $echo {
            postgres_pass    database;
            postgres_query   "select 'test' as echo";
            postgres_output  value;
        }

        echo -n  $echo;
    }
--- request
GET /eval
--- error_code: 200
--- response_headers
Content-Type: text/plain
--- response_body chomp
test
--- timeout: 10