t/10-minimal.t
changeset 9 b2a26d05b063
parent 5 2e27cfdf85ea
child 10 4243e22505f9
equal deleted inserted replaced
8:a220ea51b60b 9:b2a26d05b063
       
     1 #! perl
     1 use 5.014;
     2 use 5.014;
     2 use strict;
     3 use strict;
     3 use warnings;
     4 use warnings;
     4 use Test::More;
     5 use Test::More;
     5 use File::Temp;
     6 use File::Temp;
    21 
    22 
    22 # we require it, it's not a normal module
    23 # we require it, it's not a normal module
    23 require_ok 'blib/nagios/plugins/ius/check_dns-serial'
    24 require_ok 'blib/nagios/plugins/ius/check_dns-serial'
    24   or BAIL_OUT q{can't require the module};
    25   or BAIL_OUT q{can't require the module};
    25 
    26 
    26 is_deeply [sort +uniq(qw(a b a c))], [qw(a b c)] => 'uniq helper';
    27 
       
    28 subtest 'tools' => sub {
       
    29     is_deeply [sort +uniq(qw(a b a c))], [qw(a b c)] => 'uniq helper';
       
    30 
       
    31     my %google = ( nameservers => [qw/8.8.8.8 8.8.4.4/]);
       
    32     my %level3 = ( nameservers => [qw/209.244.0.3 209.244.0.4/]);
       
    33 
       
    34     my $r1a = Net::DNS::Resolver->new(%google);
       
    35     my $r1b = Net::DNS::Resolver->new(%google);
       
    36 
       
    37     my $r2a = Net::DNS::Resolver->new(%level3);
       
    38     my $r2b = Net::DNS::Resolver->new(%level3);
       
    39 
       
    40     is $r1a, $r1b => 'same google';
       
    41     is $r2a, $r2b => 'same level3';
       
    42     isnt $r1a, $r2a => 'not same google/level3';
       
    43 
       
    44     my @a;
       
    45     @a = qw[8.8.8.8];
       
    46     my $r3a = Net::DNS::Resolver->new(nameservers => \@a);
       
    47     @a = qw[8.8.4.4];
       
    48     my $r3b = Net::DNS::Resolver->new(nameservers => \@a);
       
    49 
       
    50     isnt $r3a, $r3b => 'same ref, but not same object';
       
    51 
       
    52 };
       
    53 
    27 
    54 
    28 # get_domains should read a list of names, either from a file
    55 # get_domains should read a list of names, either from a file
    29 # or from the arguments, or from a combination of both
    56 # or from the arguments, or from a combination of both
    30 is_deeply [get_domains(qw(a b c))], [qw(a b c)] => 'domains from list';
    57 is_deeply [get_domains(qw(a b c))], [qw(a b c)] => 'domains from list';
    31 is_deeply [get_domains("$tmp")],    [qw(a b c)] => 'domains from file';
    58 is_deeply [get_domains("$tmp")],    [qw(a b c)] => 'domains from file';
    58 throws_ok { ns_ok('heise.de', '8.8.8.8') } qr/no aa|differ|REFUSED/ => 'ns_ok for heise.de';
    85 throws_ok { ns_ok('heise.de', '8.8.8.8') } qr/no aa|differ|REFUSED/ => 'ns_ok for heise.de';
    59 
    86 
    60 # serial
    87 # serial
    61 
    88 
    62 done_testing();
    89 done_testing();
       
    90 
       
    91 # vim:sts=4 sw=4 ts=8: