Mercurial > hg > nginx-tests
comparison perl_gzip.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 | perl-gzip.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 embedded perl 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 qw/ :DEFAULT :gzip /; | |
18 | |
19 ############################################################################### | |
20 | |
21 select STDERR; $| = 1; | |
22 select STDOUT; $| = 1; | |
23 | |
24 eval { require IO::Compress::Gzip; }; | |
25 Test::More::plan(skip_all => "IO::Compress::Gzip not found") if $@; | |
26 | |
27 my $t = Test::Nginx->new()->has(qw/http perl gzip/)->plan(2) | |
28 ->write_file_expand('nginx.conf', <<'EOF'); | |
29 | |
30 %%TEST_GLOBALS%% | |
31 | |
32 master_process off; | |
33 daemon off; | |
34 | |
35 events { | |
36 } | |
37 | |
38 http { | |
39 %%TEST_GLOBALS_HTTP%% | |
40 | |
41 server { | |
42 listen 127.0.0.1:8080; | |
43 server_name localhost; | |
44 | |
45 gzip on; | |
46 gzip_types text/plain; | |
47 | |
48 location / { | |
49 perl 'sub { | |
50 my $r = shift; | |
51 $r->send_http_header("text/plain"); | |
52 return OK if $r->header_only; | |
53 $r->print("TEST"); | |
54 return OK; | |
55 }'; | |
56 } | |
57 | |
58 location /gz { | |
59 perl 'sub { | |
60 my $r = shift; | |
61 $r->header_out("Content-Encoding", "gzip"); | |
62 $r->send_http_header("text/plain"); | |
63 return OK if $r->header_only; | |
64 use IO::Compress::Gzip; | |
65 my $in = "TEST"; | |
66 my $out; | |
67 IO::Compress::Gzip::gzip(\\$in => \\$out); | |
68 $r->print($out); | |
69 return OK; | |
70 }'; | |
71 } | |
72 } | |
73 } | |
74 | |
75 EOF | |
76 | |
77 $t->run(); | |
78 | |
79 ############################################################################### | |
80 | |
81 http_gzip_like(http_gzip_request('/'), qr/TEST/, 'perl response gzipped'); | |
82 | |
83 TODO: { | |
84 local $TODO = 'patch pending'; | |
85 | |
86 http_gzip_like(http_gzip_request('/gz'), qr/TEST/, 'not doublegzipped'); | |
87 | |
88 } | |
89 | |
90 ############################################################################### |