diff options
Diffstat (limited to 't')
| -rw-r--r-- | t/Monitoring-Plugin-Getopt-01.t | 18 |
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 | ||
| 3 | use strict; | 3 | use strict; |
| 4 | 4 | ||
| 5 | use Test::More tests => 76; | 5 | use Test::More tests => 81; |
| 6 | BEGIN { use_ok('Monitoring::Plugin::Getopt') }; | 6 | BEGIN { 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; | |||
| 47 | is($ng->warning, 3, 'warning set to 3'); | 54 | is($ng->warning, 3, 'warning set to 3'); |
| 48 | is($ng->critical, 10, 'critical set to 10'); | 55 | is($ng->critical, 10, 'critical set to 10'); |
| 49 | is($ng->timeout, 12, 'timeout set to 12'); | 56 | is($ng->timeout, 12, 'timeout set to 12'); |
| 57 | is($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; | ||
| 63 | is($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'); | |||
| 131 | like($@, qr/--verbose/, 'help includes default options 2'); | 145 | like($@, qr/--verbose/, 'help includes default options 2'); |
| 132 | like($@, qr/--warning/, 'help includes custom option 1'); | 146 | like($@, qr/--warning/, 'help includes custom option 1'); |
| 133 | like($@, qr/--critical/, 'help includes custom option 2'); | 147 | like($@, qr/--critical/, 'help includes custom option 2'); |
| 148 | like($@, qr/--\[no-\]perfdata\n/, 'help includes custom option 3'); | ||
| 134 | unlike($@, qr/Missing arg/, 'no missing arguments'); | 149 | unlike($@, 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'); | |||
| 146 | like($@, qr/--verbose/, 'help includes default options 2'); | 161 | like($@, qr/--verbose/, 'help includes default options 2'); |
| 147 | like($@, qr/--warning/, 'help includes custom option 1'); | 162 | like($@, qr/--warning/, 'help includes custom option 1'); |
| 148 | like($@, qr/-c, --critical=INTEGER/, 'help includes custom option 2, with expanded args'); | 163 | like($@, qr/-c, --critical=INTEGER/, 'help includes custom option 2, with expanded args'); |
| 164 | like($@, qr/--\[no-\]perfdata\n/, 'help includes custom option 3'); | ||
| 149 | unlike($@, qr/Missing arg/, 'no missing arguments'); | 165 | unlike($@, qr/Missing arg/, 'no missing arguments'); |
