Addr-MyIP
view release on metacpan or search on metacpan
t/05-ipv4.t view on Meta::CPAN
$get_sub->reset;
$get_sub->return_value({status => 403, content => 'Unauthorized'});
my $h = Hook::Output::Tiny->new;
$h->hook;
my $ip = myip();
$h->unhook;
my @stderr = $h->stderr;
like
$stderr[0],
qr/Unauthorized/,
"on unsuccessful API call, display the error";
is $get_sub->called_count, 1, "HTTP client get called ok (mocked)";
is $ip, '', "myip() returns empty string on API fail ok";
}
}
if ($ENV{DEV_TESTING} || $ENV{RELEASE_TESTING}) {
# Valid return
{
t/10-ipv6.t view on Meta::CPAN
{
$get_sub->reset;
$get_sub->return_value({status => 403, content => 'Unauthorized'});
my $h = Hook::Output::Tiny->new;
$h->hook;
my $ip = myip6();
$h->unhook;
my @stderr = $h->stderr;
like
$stderr[0],
qr/Unauthorized/,
"on unsuccessful API call, display the error";
is $get_sub->called_count, 1, "HTTP client get called ok (mocked)";
is $ip, '', "myip() returns empty string on API fail ok";
}
}
if ($ENV{DEV_TESTING} || $ENV{RELEASE_TESTING}) {
# Valid return
( run in 0.596 second using v1.01-cache-2.11-cpan-49f99fa48dc )