summaryrefslogtreecommitdiff
path: root/redis2-nginx-module-0.15/t/if.t
blob: 2169b67b0a3aec3fa41e3277b91ee0434d140819 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# vi:ft=

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

#repeat_each(2);

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

$ENV{TEST_NGINX_REDIS_PORT} ||= 6379;

#master_on;
#worker_connections 1024;

#no_diff;
no_long_string;

#log_level 'warn';

run_tests();

__DATA__

=== TEST 1: location if (query)
--- config
    location /redis {
        set $key 'default';
        if ($uri ~ "(special.*)") {
            set $key $1;
        }
        redis2_query lrange $key 0 -1;
        redis2_pass 127.0.0.1:$TEST_NGINX_REDIS_PORT;
    }
--- request
    GET /redis/special
--- response_body eval
"*0\r\n"
--- no_error_log
[error]



=== TEST 2: location if (literal query)
--- config
    location /redis {
        if ($uri ~ "(special.*)") {
        }
        redis2_literal_raw_query 'flushall\r\n';
        redis2_pass 127.0.0.1:$TEST_NGINX_REDIS_PORT;
    }
--- request
    GET /redis/special
--- response_body eval
"+OK\r\n"
--- no_error_log
[error]



=== TEST 3: location if (raw queries)
--- config
    location /redis {
        if ($uri ~ "(special.*)") {
            set $n 2;
        }
        redis2_raw_queries $n 'flushall\r\nget foo\r\n';
        redis2_pass 127.0.0.1:$TEST_NGINX_REDIS_PORT;
    }
--- request
    GET /redis/special
--- response_body eval
"+OK\r\n\$-1\r\n"
--- no_error_log
[error]



=== TEST 4: location if (raw query)
--- config
    location /redis {
        if ($uri ~ "(special.*)") {
            set $n 2;
        }
        redis2_raw_query 'flushall\r\n';
        redis2_pass 127.0.0.1:$TEST_NGINX_REDIS_PORT;
    }
--- request
    GET /redis/special
--- response_body eval
"+OK\r\n"
--- no_error_log
[error]