summaryrefslogtreecommitdiffstats
path: root/t/Nagios-Plugin-04.t
diff options
context:
space:
mode:
Diffstat (limited to 't/Nagios-Plugin-04.t')
-rw-r--r--t/Nagios-Plugin-04.t13
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 @@
5use strict; 5use strict;
6#use Test::More 'no_plan'; 6#use Test::More 'no_plan';
7use Test::More tests=>26; 7use Test::More tests=>26;
8use Test::Exception;
9 8
10BEGIN { use_ok('Nagios::Plugin') }; 9BEGIN { use_ok('Nagios::Plugin') };
11use Nagios::Plugin::Functions; 10use Nagios::Plugin::Functions;
12Nagios::Plugin::Functions::_fake_exit(1); 11Nagios::Plugin::Functions::_fake_exit(1);
13 12
14 13
15lives_ok sub { my $broke = Nagios::Plugin->new(); }, "constructor DOESN'T die without usage"; 14eval { Nagios::Plugin->new(); };
15ok(! $@, "constructor DOESN'T die without usage");
16 16
17my $p = Nagios::Plugin->new(); 17my $p = Nagios::Plugin->new();
18dies_ok sub { $p->add_arg('warning', 'warning') }, "add_arg() dies if you haven't instantiated with usage"; 18eval { $p->add_arg('warning', 'warning') };
19dies_ok sub { $p->getopts }, "getopts() dies if you haven't instantiated with usage"; 19ok($@, "add_arg() dies if you haven't instantiated with usage");
20eval { $p->getopts };
21ok($@, "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
44dies_ok sub { $p->check_threshold() }, "check_threshold dies if called with no args"; 46eval { $p->check_threshold() };
47ok($@, "check_threshold dies if called with no args");
45 48
46 49
47# thresholds set implicitly 50# thresholds set implicitly