async_resolver: suppress test warning when

Net::DNS::Async not installed.
This commit is contained in:
Matt Simerson 2014-11-06 11:12:01 -08:00
parent 38d5523b35
commit 924dbfe5de
2 changed files with 7 additions and 5 deletions

View File

@ -63,17 +63,17 @@ sub get_async_resolver {
my ( $self, %args ) = @_;
return $self->{_async_resolver} if $self->{_async_resolver};
my $res = Net::DNS::Resolver->new(dnsrch => 0);
$res->tcp_timeout(0); # Net::DNS::Async handles its own timeouts
$res->tcp_timeout(0);
my $async_res;
eval 'use Net::DNS::Async';
if ($@) {
warn "Net::DNS::Async failed to load";
warn "could not load Net::DNS::Async, is it installed?";
return;
}
my $res = Net::DNS::Resolver->new(dnsrch => 0);
$res->tcp_timeout(0); # Net::DNS::Async handles its own timeouts
$res->tcp_timeout(0);
$self->{_async_resolver} = Net::DNS::Async->new( %args );
$self->{_async_resolver}{Resolver} = $res;
return $self->{_async_resolver};

View File

@ -64,6 +64,8 @@ sub __get_resolver {
}
sub __get_async_resolver {
eval 'use Net::DNS::Async';
return if ($@);
my $res = $base->get_async_resolver() or return;
isa_ok( $res, 'Net::DNS::Async', "resolver object, $res");
isa_ok( $res->{Resolver}, 'Net::DNS::Resolver', "resolver object, $res");