# HG changeset patch # User Maxim Dounin # Date 1605623949 -10800 # Node ID 8659123d2d375974bc87dedaaf73dfe22299be4e # Parent dbeb4c896f7ee7aac0b757aede99687ce720fb58 Tests: made http_content() exportable. diff --git a/http_host.t b/http_host.t --- a/http_host.t +++ b/http_host.t @@ -15,7 +15,7 @@ use Test::More; BEGIN { use FindBin; chdir($FindBin::Bin); } use lib 'lib'; -use Test::Nginx; +use Test::Nginx qw/ :DEFAULT http_content /; ############################################################################### @@ -185,7 +185,7 @@ GET / HTTP/1.0 Host: $host EOF - return ($all ? $r : Test::Nginx::http_content($r)); + return ($all ? $r : http_content($r)); } sub http_absolute_path { @@ -195,7 +195,7 @@ GET http://$host/ HTTP/1.0 Host: localhost EOF - return ($all ? $r : Test::Nginx::http_content($r)); + return ($all ? $r : http_content($r)); } ############################################################################### diff --git a/lib/Test/Nginx.pm b/lib/Test/Nginx.pm --- a/lib/Test/Nginx.pm +++ b/lib/Test/Nginx.pm @@ -12,7 +12,9 @@ use strict; use base qw/ Exporter /; our @EXPORT = qw/ log_in log_out http http_get http_head port /; -our @EXPORT_OK = qw/ http_gzip_request http_gzip_like http_start http_end /; +our @EXPORT_OK = qw/ + http_gzip_request http_gzip_like http_start http_end http_content +/; our %EXPORT_TAGS = ( gzip => [ qw/ http_gzip_request http_gzip_like / ] ); diff --git a/mp4.t b/mp4.t --- a/mp4.t +++ b/mp4.t @@ -16,7 +16,7 @@ use Test::More; BEGIN { use FindBin; chdir($FindBin::Bin); } use lib 'lib'; -use Test::Nginx; +use Test::Nginx qw/ :DEFAULT http_content /; ############################################################################### @@ -144,7 +144,7 @@ sub durations { $uri .= "?end=$end"; } - $t->write_file('frag.mp4', Test::Nginx::http_content(http_get($uri))); + $t->write_file('frag.mp4', http_content(http_get($uri))); my $r = `ffprobe -show_streams $path 2>/dev/null`; Test::Nginx::log_core('||', $r); diff --git a/proxy_unfinished.t b/proxy_unfinished.t --- a/proxy_unfinished.t +++ b/proxy_unfinished.t @@ -24,7 +24,7 @@ use Socket qw/ CRLF /; BEGIN { use FindBin; chdir($FindBin::Bin); } use lib 'lib'; -use Test::Nginx; +use Test::Nginx qw/ :DEFAULT http_content /; ############################################################################### @@ -144,7 +144,7 @@ chmod(0000, $t->testdir() . '/proxy_temp my $r = http_get_11('/proxy/big.html', sleep => 0.5); SKIP: { -skip 'finished', 1 if length(Test::Nginx::http_content($r)) == 1024 * 1024 + 8; +skip 'finished', 1 if length(http_content($r)) == 1024 * 1024 + 8; like($r, qr/X(?!.*\x0d\x0a?0\x0d\x0a?)/s, 'no proxy temp'); diff --git a/sub_filter_slice.t b/sub_filter_slice.t --- a/sub_filter_slice.t +++ b/sub_filter_slice.t @@ -17,7 +17,7 @@ use Test::More; BEGIN { use FindBin; chdir($FindBin::Bin); } use lib 'lib'; -use Test::Nginx; +use Test::Nginx qw/ :DEFAULT http_content /; ############################################################################### @@ -83,7 +83,7 @@ local $TODO = 'not yet'; $r = get('/t', 'Range: bytes=3-4'); like($r, qr/ 206 /, 'range request - 206 partial reply'); -is(Test::Nginx::http_content($r), '34', 'range request - correct content'); +is(http_content($r), '34', 'range request - correct content'); }