Skip to content

Commit

Permalink
Add get method coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
kentfredric committed Jul 17, 2014
1 parent 1c44fee commit 408eb57
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ Release history for HTTP-Tiny-Mech
{{$NEXT}}
[00 Major]
- Recoded construction to work without Class::Tiny, as the logic is much more difficult since 1.000
- Test Coverage increased to 100%
- Misc packaging cleanups

[Dependencies::Stats]
- Dependencies changed since 1.000000, see misc/*.deps* for details
- develop: +3 -3 (suggests: +2 -1)
- runtime: -1
- test: +1

1.000000 2014-05-10T02:41:46Z
[00 Minor]
Expand Down
3 changes: 3 additions & 0 deletions misc/Changes.deps
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
This file contains changes in REQUIRED dependencies for standard CPAN phases (configure/build/runtime/test)

1.000001
[Added / test requires]
- HTTP::Response

[Removed / runtime requires]
- Class::Tiny

Expand Down
3 changes: 3 additions & 0 deletions misc/Changes.deps.all
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ This file contains ALL changes in dependencies in both REQUIRED / OPTIONAL depen
- Dist::Zilla::App::Command::bakeini 0.001001
- Dist::Zilla::PluginBundle::Author::KENTNL 2.016004

[Added / test requires]
- HTTP::Response

[Removed / develop requires]
- Dist::Zilla::Plugin::Git::NextVersion::Sanitized
- Dist::Zilla::Plugin::PkgVersion
Expand Down
66 changes: 66 additions & 0 deletions t/get.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
use strict;
use warnings;

use Test::More;

# ABSTRACT: Test ->get with a dummy class

use HTTP::Tiny::Mech;
use HTTP::Tiny 0.022;

{

package FakeUA;
our $AUTOLOAD;

sub AUTOLOAD {
my $program = $AUTOLOAD;
$program =~ s/.*:://;

my ( $self, @args ) = @_;
push @{ $self->{calls} }, [ $program, @args ];
require HTTP::Response;
return HTTP::Response->new();
}

sub new {
my ( $self, @args ) = @_;
bless { args => \@args, calls => [] }, $self;
}

}

my $instance = HTTP::Tiny::Mech->new( mechua => FakeUA->new(), );
isa_ok( $instance, 'HTTP::Tiny' );
isa_ok( $instance, 'HTTP::Tiny::Mech' );
isa_ok( $instance->mechua, 'FakeUA' );

subtest "get url" => sub {
local $instance->mechua->{calls} = [];
my $result = $instance->get('http://www.example.org:80/');
is( ref $result, 'HASH', "Got a hash back" );
note explain $instance;
};

subtest "get url + opts" => sub {
local $instance->mechua->{calls} = [];
my $result = $instance->get( 'http://www.example.org:80/', { args => {} } );
is( ref $result, 'HASH', "Got a hash back" );
note explain $instance;
};

subtest "request url" => sub {
local $instance->mechua->{calls} = [];
my $result = $instance->request( 'HEAD', 'http://www.example.org:80/' );
is( ref $result, 'HASH', "Got a hash back" );
note explain $instance;
};
subtest "request url + opts" => sub {
local $instance->mechua->{calls} = [];
my $result = $instance->request( 'POST', 'http://www.example.org:80/', { headers => {}, content => "CONTENT" } );
is( ref $result, 'HASH', "Got a hash back" );
note explain $instance;
};

done_testing;

0 comments on commit 408eb57

Please sign in to comment.