Commit d3d734da authored by David Golden's avatar David Golden

fix t/002_croakage.t

parent 02c979b3
......@@ -2,6 +2,10 @@ Release notes for HTTP-Tiny
{{$NEXT}}
[FIXED]
- Fixed t/002_croakage.t for various operating systems.
0.044 2014-07-16 23:46:09-04:00 America/New_York
[CHANGED]
......
......@@ -4,8 +4,12 @@ use strict;
use warnings;
use Test::More;
use t::Util qw[tmpfile monkey_patch set_socket_source];
use HTTP::Tiny;
BEGIN { monkey_patch() }
my %usage = (
'get' => q/Usage: $http->get(URL, [HASHREF])/,
'mirror' => q/Usage: $http->mirror(URL, FILE, [HASHREF])/,
......@@ -26,7 +30,11 @@ my @cases = (
['request','GET','http://www.example.com/','extra', 'extra'],
);
my $res_fh = tmpfile();
my $req_fh = tmpfile();
my $http = HTTP::Tiny->new;
set_socket_source($req_fh, $res_fh);
for my $c ( @cases ) {
my ($method, @args) = @$c;
......@@ -35,8 +43,9 @@ for my $c ( @cases ) {
like ($err, qr/\Q$usage{$method}\E/, join("|",@$c) );
}
my $res = $http->get("http://www.example.com/", { headers => { host => "www.example2.com" } } );
like( $res->{content}, qr/'Host' header/, "Providing a Host header is fatal" );
my $res = eval{ $http->get("http://www.example.com/", { headers => { host => "www.example2.com" } } ) };
is( $res->{status}, 599, "Providing a Host header errors with 599" );
like( $res->{content}, qr/'Host' header/, "Providing a Host header gives right error message" );
done_testing;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment