Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Clean up test suite to work with older Test::More.

Also specify a minimum Test::More that supports subtest().
  • Loading branch information...
commit e63c1a71610657ec7ca7738aae6e522f961a586a 1 parent b721074
@rjray authored
Showing with 24 additions and 13 deletions.
  1. +1 −1  Makefile.PL
  2. +23 −12 t/51_client_with_host_header.t
View
2  Makefile.PL
@@ -91,7 +91,7 @@ WriteMakefile(
'File::Spec' => 0.8,
'constant' => 1.03,
'Scalar::Util' => 1.19,
- 'Test::More' => 0,
+ 'Test::More' => 0.94,
'LWP' => 5.834,
'XML::Parser' => 2.31,
},
View
35 t/51_client_with_host_header.t
@@ -1,3 +1,7 @@
+#!/usr/bin/perl
+
+# Test the ability of requests to specify their own Host: header
+
use strict;
use warnings;
@@ -6,31 +10,38 @@ use Test::More;
plan tests => 2;
-sub clone_with_host_header {
+sub clone_with_host_header
+{
my $req = shift;
my $reqclone = $req->clone;
- unless ( $reqclone->header('Host') ) {
- $reqclone->header( Host => URI->new( $reqclone->uri )->host );
+ unless ($reqclone->header('Host'))
+ {
+ $reqclone->header(Host => URI->new($reqclone->uri)->host);
}
return $reqclone;
}
subtest "without_host_header" => sub {
- my $req = HTTP::Request->new( POST => 'http://example.com' );
- ok( !$req->header('Host') );
+ plan tests => 2;
+
+ my $req = HTTP::Request->new(POST => 'http://example.com');
+ ok(! $req->header('Host'), 'Host: header not set');
my $reqclone = clone_with_host_header($req);
- ok( $reqclone->header('Host'), 'example.com' );
+ is($reqclone->header('Host'), 'example.com', 'Host: header set properly');
};
subtest "with_host_header" => sub {
- my $req = HTTP::Request->new( POST => 'http://example.com' );
- ok( !$req->header('Host') );
- $req->header( 'Host', 'google.com' );
- is( $req->header('Host'), 'google.com' );
+ plan tests => 3;
+
+ my $req = HTTP::Request->new(POST => 'http://example.com');
+ ok(! $req->header('Host'), 'Host: header not set');
+ $req->header('Host', 'google.com');
+ is($req->header('Host'), 'google.com', 'Host: header set properly');
my $reqclone = clone_with_host_header($req);
- ok( $reqclone->header('Host'), 'google.com' );
+ is($reqclone->header('Host'), 'google.com',
+ 'Host: header in clone is correct');
};
-done_testing;
+exit;
Please sign in to comment.
Something went wrong with that request. Please try again.