comparison map_volatile.t @ 1095:b16d30a52753

Tests: map module basic tests with volatile.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 13 Dec 2016 18:27:00 +0300
parents
children 766bcbb632ee
comparison
equal deleted inserted replaced
1094:dd8f126afa32 1095:b16d30a52753
1 #!/usr/bin/perl
2
3 # (C) Sergey Kandaurov
4 # (C) Nginx, Inc.
5
6 # Tests for map module with volatile.
7
8 ###############################################################################
9
10 use warnings;
11 use strict;
12
13 use Test::More;
14
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
16
17 use lib 'lib';
18 use Test::Nginx;
19
20 ###############################################################################
21
22 select STDERR; $| = 1;
23 select STDOUT; $| = 1;
24
25 my $t = Test::Nginx->new()->has(qw/http map/);
26
27 $t->write_file_expand('nginx.conf', <<'EOF');
28
29 %%TEST_GLOBALS%%
30
31 daemon off;
32
33 events {
34 }
35
36 http {
37 %%TEST_GLOBALS_HTTP%%
38
39 map $uri $uri_cached {
40 /1/ /1/redirect;
41 /1/redirect uncached;
42 }
43
44 map $uri $uri_uncached {
45 volatile;
46
47 /2/ /2/redirect;
48 /2/redirect uncached;
49 }
50
51 server {
52 listen 127.0.0.1:8080;
53 server_name localhost;
54
55 location /1 {
56 index $uri_cached;
57 }
58 location /1/redirect {
59 add_header X-URI $uri_cached always;
60 }
61
62 location /2 {
63 index $uri_uncached;
64 }
65 location /2/redirect {
66 add_header X-URI $uri_uncached always;
67 }
68 }
69 }
70
71 EOF
72
73 mkdir($t->testdir() . '/1');
74 mkdir($t->testdir() . '/2');
75
76 $t->try_run('no map volatile')->plan(2);
77
78 ###############################################################################
79
80 like(http_get('/1/'), qr!X-URI: /1/redirect!, 'map');
81 like(http_get('/2/'), qr/X-URI: uncached/, 'map volatile');
82
83 ###############################################################################