changeset 1612:8659123d2d37

Tests: made http_content() exportable.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 17 Nov 2020 17:39:09 +0300
parents dbeb4c896f7e
children d7ec131d305a
files http_host.t lib/Test/Nginx.pm mp4.t proxy_unfinished.t sub_filter_slice.t
diffstat 5 files changed, 12 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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));
 }
 
 ###############################################################################
--- 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 / ]
 );
--- 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);
--- 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');
 
--- 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');
 
 }