File: 60flexible-attributes.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 (41 lines) | stat: -r--r--r-- 967 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
#!/usr/bin/perl -w

use strict;
use Test::More qw(no_plan);
use Test::NoWarnings;
use Test::Exception;
use Scalar::Util qw(blessed);
use lib qw( ../lib ./lib );
use Data::Dumper;

eval { chdir('t') };

use Nagios::Config;

my $lax = Nagios::Object::Config->new();
lives_ok(
    sub { $lax->parse('60flexible-attributes1.cfg') },
    "parse() does not throw exceptions by default"
);

my @contacts = $lax->list_contacts;
lives_ok(
    sub { $contacts[0]->random_one },
    "Verify that get method was instantiated"
);
lives_ok(
    sub { $contacts[0]->set_random_one('foobar') },
    "Verify that set method was instantiated"
);

# enable strict mode
Nagios::Object::Config->strict_mode(1);
my $strict = Nagios::Object::Config->new();
dies_ok(
    sub { $strict->parse('60flexible-attributes2.cfg') },
    "parse() throws exceptions with strict_mode"
);

dies_ok( sub { $contacts[0]->random_four },
    "verify that no methods were instantiated under strict_mode" );