diff options
Diffstat (limited to 't/Nagios-Plugin-04.t')
-rw-r--r-- | t/Nagios-Plugin-04.t | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/t/Nagios-Plugin-04.t b/t/Nagios-Plugin-04.t index a110b4c..6f31b56 100644 --- a/t/Nagios-Plugin-04.t +++ b/t/Nagios-Plugin-04.t | |||
@@ -5,18 +5,20 @@ | |||
5 | use strict; | 5 | use strict; |
6 | #use Test::More 'no_plan'; | 6 | #use Test::More 'no_plan'; |
7 | use Test::More tests=>26; | 7 | use Test::More tests=>26; |
8 | use Test::Exception; | ||
9 | 8 | ||
10 | BEGIN { use_ok('Nagios::Plugin') }; | 9 | BEGIN { use_ok('Nagios::Plugin') }; |
11 | use Nagios::Plugin::Functions; | 10 | use Nagios::Plugin::Functions; |
12 | Nagios::Plugin::Functions::_fake_exit(1); | 11 | Nagios::Plugin::Functions::_fake_exit(1); |
13 | 12 | ||
14 | 13 | ||
15 | lives_ok sub { my $broke = Nagios::Plugin->new(); }, "constructor DOESN'T die without usage"; | 14 | eval { Nagios::Plugin->new(); }; |
15 | ok(! $@, "constructor DOESN'T die without usage"); | ||
16 | 16 | ||
17 | my $p = Nagios::Plugin->new(); | 17 | my $p = Nagios::Plugin->new(); |
18 | dies_ok sub { $p->add_arg('warning', 'warning') }, "add_arg() dies if you haven't instantiated with usage"; | 18 | eval { $p->add_arg('warning', 'warning') }; |
19 | dies_ok sub { $p->getopts }, "getopts() dies if you haven't instantiated with usage"; | 19 | ok($@, "add_arg() dies if you haven't instantiated with usage"); |
20 | eval { $p->getopts }; | ||
21 | ok($@, "getopts() dies if you haven't instantiated with usage"); | ||
20 | 22 | ||
21 | $p = Nagios::Plugin->new( usage => "dummy usage statement" ); | 23 | $p = Nagios::Plugin->new( usage => "dummy usage statement" ); |
22 | 24 | ||
@@ -41,7 +43,8 @@ can_ok $p, 'threshold'; | |||
41 | #isa_ok $p->threshold, 'Nagios::Plugin::Threshold', "threshold object is defined"; | 43 | #isa_ok $p->threshold, 'Nagios::Plugin::Threshold', "threshold object is defined"; |
42 | 44 | ||
43 | 45 | ||
44 | dies_ok sub { $p->check_threshold() }, "check_threshold dies if called with no args"; | 46 | eval { $p->check_threshold() }; |
47 | ok($@, "check_threshold dies if called with no args"); | ||
45 | 48 | ||
46 | 49 | ||
47 | # thresholds set implicitly | 50 | # thresholds set implicitly |