1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
7use Net::DNS::Packet;
8
9eval { require Net::LibResolv and Net::LibResolv->VERSION(0.03) } or
10   plan skip_all => "Missing Net::LibResolv";
11
12require IO::Async::Resolver::DNS::LibResolvImpl;
13
14my $data = IO::Async::Resolver::DNS::res_query( "www.cpan.org", "IN", "A" );
15ok( defined $data, 'res_query' );
16
17my $pkt = Net::DNS::Packet->new( \$data );
18ok( defined $pkt, 'res_query returns valid DNS packet' );
19
20# Since we don't want to be too sensitive to what DNS actually claims about
21# www.cpan.org at the current time, just check the question is what we asked
22is( ($pkt->question)[0]->qname,  "www.cpan.org", '$pkt qname' );
23is( ($pkt->question)[0]->qclass, "IN",           '$pkt qclass' );
24is( ($pkt->question)[0]->qtype,  "A",            '$pkt qtype' );
25
26ok( defined IO::Async::Resolver::DNS::res_search( "www.cpan.org", "IN", "A" ),
27    'res_search' );
28
29done_testing;
30