comparison not_modified.t @ 148:b714d6df958c

Tests: rename some tests for better sorting. Use underscore instead of dash. Addtionally, rename some tests to better match "module" + "details" scheme used: use "http_" prefix for http core module tests, use "mail_" prefix for mail module tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 04 Mar 2011 16:07:15 +0300
parents not-modified.t@8ac1faaddd2c
children c0ae29632905
comparison
equal deleted inserted replaced
147:fd865ada95c8 148:b714d6df958c
1 #!/usr/bin/perl
2
3 # (C) Maxim Dounin
4
5 # Tests for not modified filter module.
6
7 ###############################################################################
8
9 use warnings;
10 use strict;
11
12 use Test::More;
13
14 BEGIN { use FindBin; chdir($FindBin::Bin); }
15
16 use lib 'lib';
17 use Test::Nginx;
18
19 ###############################################################################
20
21 select STDERR; $| = 1;
22 select STDOUT; $| = 1;
23
24 my $t = Test::Nginx->new()->has('http')->plan(4)
25 ->write_file_expand('nginx.conf', <<'EOF');
26
27 %%TEST_GLOBALS%%
28
29 master_process off;
30 daemon off;
31
32 events {
33 }
34
35 http {
36 %%TEST_GLOBALS_HTTP%%
37
38 server {
39 listen 127.0.0.1:8080;
40 server_name localhost;
41
42 location / {
43 if_modified_since before;
44 }
45 }
46 }
47
48 EOF
49
50 $t->write_file('t', '');
51
52 $t->run();
53
54 ###############################################################################
55
56 like(http_get_ims('/t', 'Wed, 08 Jul 2037 22:53:52 GMT'), qr/304/,
57 '0x7F000000');
58 like(http_get_ims('/t', 'Tue, 19 Jan 2038 03:14:07 GMT'), qr/304/,
59 '0x7FFFFFFF');
60
61 SKIP: {
62 skip "only for 32-bit time_t", 2 if (gmtime(0xFFFFFFFF))[5] == 206;
63
64 like(http_get_ims('/t', 'Tue, 19 Jan 2038 03:14:08 GMT'), qr/200/,
65 '0x7FFFFFFF + 1');
66 like(http_get_ims('/t', 'Fri, 25 Feb 2174 09:42:23 GMT'), qr/200/,
67 '0x17FFFFFFF');
68 }
69
70 ###############################################################################
71
72 sub http_get_ims {
73 my ($url, $ims) = @_;
74 return http(<<EOF);
75 GET $url HTTP/1.0
76 Host: localhost
77 If-Modified-Since: $ims
78
79 EOF
80 }
81
82 ###############################################################################