summaryrefslogtreecommitdiffstats
path: root/t/Monitoring-Plugin-Getopt-01.t
diff options
context:
space:
mode:
Diffstat (limited to 't/Monitoring-Plugin-Getopt-01.t')
-rw-r--r--t/Monitoring-Plugin-Getopt-01.t18
1 files changed, 17 insertions, 1 deletions
diff --git a/t/Monitoring-Plugin-Getopt-01.t b/t/Monitoring-Plugin-Getopt-01.t
index 36f1f55..5c57df7 100644
--- a/t/Monitoring-Plugin-Getopt-01.t
+++ b/t/Monitoring-Plugin-Getopt-01.t
@@ -2,7 +2,7 @@
2 2
3use strict; 3use strict;
4 4
5use Test::More tests => 76; 5use Test::More tests => 81;
6BEGIN { use_ok('Monitoring::Plugin::Getopt') }; 6BEGIN { use_ok('Monitoring::Plugin::Getopt') };
7 7
8# Needed to get evals to work in testing 8# Needed to get evals to work in testing
@@ -35,6 +35,13 @@ sub setup
35 required => 1, 35 required => 1,
36 ); 36 );
37 37
38 # Add argument - boolean, supporting --no-prefix
39 $ng->arg(
40 spec => 'perfdata!',
41 help => qq(Provide performance data),
42 default => 1,
43 );
44
38 return $ng; 45 return $ng;
39} 46}
40 47
@@ -47,6 +54,13 @@ $ng->getopts;
47is($ng->warning, 3, 'warning set to 3'); 54is($ng->warning, 3, 'warning set to 3');
48is($ng->critical, 10, 'critical set to 10'); 55is($ng->critical, 10, 'critical set to 10');
49is($ng->timeout, 12, 'timeout set to 12'); 56is($ng->timeout, 12, 'timeout set to 12');
57is($ng->perfdata, 1, 'perfdata set to default of 1');
58
59# Disable perfdata
60@ARGV = qw(--critical 10 --no-perfdata);
61$ng = setup;
62$ng->getopts;
63is($ng->perfdata, 0, 'perfdata set to 0');
50 64
51# Check multiple verbose flags 65# Check multiple verbose flags
52@ARGV = qw(-w 3 --critical 10 -v -v -v); 66@ARGV = qw(-w 3 --critical 10 -v -v -v);
@@ -131,6 +145,7 @@ like($@, qr/--version/, 'help includes default options 1');
131like($@, qr/--verbose/, 'help includes default options 2'); 145like($@, qr/--verbose/, 'help includes default options 2');
132like($@, qr/--warning/, 'help includes custom option 1'); 146like($@, qr/--warning/, 'help includes custom option 1');
133like($@, qr/--critical/, 'help includes custom option 2'); 147like($@, qr/--critical/, 'help includes custom option 2');
148like($@, qr/--\[no-\]perfdata\n/, 'help includes custom option 3');
134unlike($@, qr/Missing arg/, 'no missing arguments'); 149unlike($@, qr/Missing arg/, 'no missing arguments');
135 150
136@ARGV = ( '--help' ); 151@ARGV = ( '--help' );
@@ -146,4 +161,5 @@ like($@, qr/--version/, 'help includes default options 1');
146like($@, qr/--verbose/, 'help includes default options 2'); 161like($@, qr/--verbose/, 'help includes default options 2');
147like($@, qr/--warning/, 'help includes custom option 1'); 162like($@, qr/--warning/, 'help includes custom option 1');
148like($@, qr/-c, --critical=INTEGER/, 'help includes custom option 2, with expanded args'); 163like($@, qr/-c, --critical=INTEGER/, 'help includes custom option 2, with expanded args');
164like($@, qr/--\[no-\]perfdata\n/, 'help includes custom option 3');
149unlike($@, qr/Missing arg/, 'no missing arguments'); 165unlike($@, qr/Missing arg/, 'no missing arguments');