File: 51config-wildcards.t

package info (click to toggle)
libnagios-object-perl 0.21.20-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,032 kB
  • sloc: perl: 3,198; makefile: 9
file content (47 lines) | stat: -r--r--r-- 1,077 bytes parent folder | download | duplicates (6)
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
41
42
43
44
45
46
47
#!/usr/local/bin/perl

use strict;
use Test::More qw(no_plan);
use Test::NoWarnings;
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 ....