changeset 4:2698bf018167

Gunzip: add tests for replies from gzip_static always.
author Maxim Dounin <mdounin@mdounin.ru>
date Sun, 27 Dec 2009 03:45:37 +0300
parents 7170c171150c
children d8e85fd12fab
files t/gunzip-static.t
diffstat 1 files changed, 12 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
copy from t/gunzip.t
copy to t/gunzip-static.t
--- a/t/gunzip.t
+++ b/t/gunzip-static.t
@@ -2,7 +2,8 @@
 
 # (C) Maxim Dounin
 
-# Tests for gunzip filter module.
+# Tests for gunzip filter module with gzip_static always.  It is basically
+# the copy of gunzip.t with minor modifications.
 
 ###############################################################################
 
@@ -20,7 +21,7 @@ select STDOUT; $| = 1;
 eval { require IO::Compress::Gzip; };
 Test::More::plan(skip_all => "IO::Compress::Gzip not found") if $@;
 
-my $t = Test::Nginx->new()->has(qw/http proxy gzip_static/)->plan(12);
+my $t = Test::Nginx->new()->has(qw/http proxy gzip_static/);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -44,26 +45,13 @@ http {
         location / {
             gunzip on;
             gzip_vary on;
-            proxy_pass http://127.0.0.1:8081/;
-            proxy_set_header Accept-Encoding gzip;
+            gzip_static always;
         }
         location /error {
             error_page 500 /t1;
             return 500;
         }
     }
-
-    server {
-        listen       127.0.0.1:8081;
-        server_name  localhost;
-
-        location / {
-            default_type text/plain;
-            gzip_static on;
-            gzip_http_version 1.0;
-            gzip_types text/plain;
-        }
-    }
 }
 
 EOF
@@ -77,7 +65,14 @@ IO::Compress::Gzip::gzip(\$in => \$out);
 $t->write_file('t2.gz', $out . $out);
 $t->write_file('t3', 'not compressed');
 
-$t->run();
+eval {
+	open OLDERR, ">&", \*STDERR; close STDERR;
+	$t->run();
+	open STDERR, ">&", \*OLDERR;
+};
+plan(skip_all => 'no gzip_static always') if $@;
+
+$t->plan(12);
 
 ###############################################################################