File: 51config-wildcards.t

package info (click to toggle)
libnagios-object-perl 0.14-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 512 kB
  • ctags: 112
  • sloc: perl: 1,804; makefile: 53
file content (40 lines) | stat: -rw-r--r-- 1,042 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use strict;
use Test::More qw(no_plan);
use lib qw( ./lib ../lib );
use Data::Dumper;
#BEGIN { plan tests => 7; }
eval { chdir('t') };

use_ok( 'Nagios::Object::Config' );

ok( my $cf = Nagios::Object::Config->new(
                Version => 2.0,
                true_regexp_matching => 1
             ),
    "Nagios::Object::Config->new()" );
$cf->parse( 'v2_wildcards.cfg' );  

ok( $cf->resolve_objects, "Run resolve_objects method." );
ok( $cf->register_objects, "Run register_objects method." );

ok( my @cgs = $cf->list_contactgroups, "List contact groups" );

is( scalar(@cgs), 1, "There should be only 1 contactgroup." );
my $cg = $cgs[0];

my $contacts = $cg->members;
is( scalar(@$contacts), 2, "Wildcard should have matched exactly two contacts." );

my @hgs = $cf->list_hostgroups;
my $printer_hg;
foreach ( @hgs ) {
    if ( $_->name eq 'printers' ) {
        $printer_hg = $_;
    }
}

my $printers = $printer_hg->members;
is( scalar(@$printers), 3, "\"prin\" should have matched all three printers." );

# add more tests ....