diff options
author | Nathan Vonnahme <n8v@users.sourceforge.net> | 2006-11-15 02:11:10 +0000 |
---|---|---|
committer | Nathan Vonnahme <n8v@users.sourceforge.net> | 2006-11-15 02:11:10 +0000 |
commit | 22509ac75b3ae04f35b22c87bbd85c643bb1db2b (patch) | |
tree | 8423e25fd60ca9c275aa890817b96ae9d50d168f /t | |
parent | 79b36b4d71afeb016a3b4764b6b484754323b011 (diff) | |
download | monitoring-plugin-perl-22509ac75b3ae04f35b22c87bbd85c643bb1db2b.tar.gz |
made 'usage' unmandatory in N::P::new().
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1538 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 't')
-rw-r--r-- | t/Nagios-Plugin-01.t | 6 | ||||
-rw-r--r-- | t/Nagios-Plugin-02.t | 4 | ||||
-rw-r--r-- | t/Nagios-Plugin-03.t | 26 |
3 files changed, 18 insertions, 18 deletions
diff --git a/t/Nagios-Plugin-01.t b/t/Nagios-Plugin-01.t index a73fce4..db12c35 100644 --- a/t/Nagios-Plugin-01.t +++ b/t/Nagios-Plugin-01.t | |||
@@ -11,16 +11,16 @@ Nagios::Plugin::Functions::_fake_exit(1); | |||
11 | diag "\nusing Nagios::Plugin revision ". $Nagios::Plugin::VERSION . "\n" | 11 | diag "\nusing Nagios::Plugin revision ". $Nagios::Plugin::VERSION . "\n" |
12 | if $ENV{TEST_VERBOSE}; | 12 | if $ENV{TEST_VERBOSE}; |
13 | 13 | ||
14 | my $p = Nagios::Plugin->new (usage => "dummy usage"); | 14 | my $p = Nagios::Plugin->new(); |
15 | isa_ok( $p, "Nagios::Plugin"); | 15 | isa_ok( $p, "Nagios::Plugin"); |
16 | 16 | ||
17 | $p->shortname("PAGESIZE"); | 17 | $p->shortname("PAGESIZE"); |
18 | is($p->shortname, "PAGESIZE", "shortname explicitly set correctly"); | 18 | is($p->shortname, "PAGESIZE", "shortname explicitly set correctly"); |
19 | 19 | ||
20 | $p = Nagios::Plugin->new (usage => "dummy usage"); | 20 | $p = Nagios::Plugin->new(); |
21 | is($p->shortname, "NAGIOS-PLUGIN-01", "shortname should default on new"); | 21 | is($p->shortname, "NAGIOS-PLUGIN-01", "shortname should default on new"); |
22 | 22 | ||
23 | $p = Nagios::Plugin->new( shortname => "SIZE", usage => "dummy usage" ); | 23 | $p = Nagios::Plugin->new( shortname => "SIZE", () ); |
24 | is($p->shortname, "SIZE", "shortname set correctly on new"); | 24 | is($p->shortname, "SIZE", "shortname set correctly on new"); |
25 | 25 | ||
26 | diag "warn if < 10, critical if > 25 " if $ENV{TEST_VERBOSE}; | 26 | diag "warn if < 10, critical if > 25 " if $ENV{TEST_VERBOSE}; |
diff --git a/t/Nagios-Plugin-02.t b/t/Nagios-Plugin-02.t index 15ae3d6..f64fb6f 100644 --- a/t/Nagios-Plugin-02.t +++ b/t/Nagios-Plugin-02.t | |||
@@ -16,7 +16,7 @@ is(UNKNOWN, $ERRORS{UNKNOWN}, "UNKNOWN => $ERRORS{UNKNOWN}"); | |||
16 | is(DEPENDENT, $ERRORS{DEPENDENT}, "DEPENDENT => $ERRORS{DEPENDENT}"); | 16 | is(DEPENDENT, $ERRORS{DEPENDENT}, "DEPENDENT => $ERRORS{DEPENDENT}"); |
17 | 17 | ||
18 | my $plugin = 'TEST_PLUGIN'; | 18 | my $plugin = 'TEST_PLUGIN'; |
19 | my $np = Nagios::Plugin->new( shortname => $plugin, usage => "dummy usage" ); | 19 | my $np = Nagios::Plugin->new( shortname => $plugin ); |
20 | is($np->shortname, $plugin, "shortname() is $plugin"); | 20 | is($np->shortname, $plugin, "shortname() is $plugin"); |
21 | 21 | ||
22 | # Test nagios_exit( CONSTANT, $msg ), nagios_exit( $string, $msg ) | 22 | # Test nagios_exit( CONSTANT, $msg ), nagios_exit( $string, $msg ) |
@@ -151,7 +151,7 @@ for (@ok) { | |||
151 | # shortname testing | 151 | # shortname testing |
152 | SKIP: { | 152 | SKIP: { |
153 | skip "requires File::Basename", 2 unless eval { require File::Basename }; | 153 | skip "requires File::Basename", 2 unless eval { require File::Basename }; |
154 | $np = Nagios::Plugin->new (usage => "dummy usage", version => "1"); | 154 | $np = Nagios::Plugin->new( version => "1"); |
155 | $plugin = uc File::Basename::basename($0); | 155 | $plugin = uc File::Basename::basename($0); |
156 | $plugin =~ s/\..*$//; | 156 | $plugin =~ s/\..*$//; |
157 | is($np->shortname, $plugin, "shortname() is '$plugin'"); | 157 | is($np->shortname, $plugin, "shortname() is '$plugin'"); |
diff --git a/t/Nagios-Plugin-03.t b/t/Nagios-Plugin-03.t index 0b7b8af..bc4f5e3 100644 --- a/t/Nagios-Plugin-03.t +++ b/t/Nagios-Plugin-03.t | |||
@@ -10,7 +10,7 @@ BEGIN { | |||
10 | Nagios::Plugin::Functions::_fake_exit(1); | 10 | Nagios::Plugin::Functions::_fake_exit(1); |
11 | 11 | ||
12 | my $plugin = 'NP_CHECK_MESSAGES_03'; | 12 | my $plugin = 'NP_CHECK_MESSAGES_03'; |
13 | my $np = Nagios::Plugin->new( shortname => $plugin, usage => "dummy usage" ); | 13 | my $np = Nagios::Plugin->new( shortname => $plugin, () ); |
14 | is($np->shortname, $plugin, "shortname() is $plugin"); | 14 | is($np->shortname, $plugin, "shortname() is $plugin"); |
15 | 15 | ||
16 | my ($code, $message); | 16 | my ($code, $message); |
@@ -172,33 +172,33 @@ is($message, 'D E F', "join_all '$join_all' (critical, warning) message is $mess | |||
172 | # add_messages | 172 | # add_messages |
173 | 173 | ||
174 | # Constant codes | 174 | # Constant codes |
175 | $np = Nagios::Plugin->new (usage => "dummy usage"); | 175 | $np = Nagios::Plugin->new(); |
176 | $np->add_message( CRITICAL, "A B C" ); | 176 | $np->add_message( CRITICAL, "A B C" ); |
177 | $np->add_message( WARNING, "D E F" ); | 177 | $np->add_message( WARNING, "D E F" ); |
178 | ($code, $message) = $np->check_messages(); | 178 | ($code, $message) = $np->check_messages(); |
179 | is($code, CRITICAL, "(CRITICAL, WARNING) code is $STATUS_TEXT{$code}"); | 179 | is($code, CRITICAL, "(CRITICAL, WARNING) code is $STATUS_TEXT{$code}"); |
180 | is($message, $messages{critical}, "(CRITICAL, WARNING) message is $message"); | 180 | is($message, $messages{critical}, "(CRITICAL, WARNING) message is $message"); |
181 | 181 | ||
182 | $np = Nagios::Plugin->new (usage => "dummy usage"); | 182 | $np = Nagios::Plugin->new(); |
183 | $np->add_message( CRITICAL, "A B C" ); | 183 | $np->add_message( CRITICAL, "A B C" ); |
184 | ($code, $message) = $np->check_messages(); | 184 | ($code, $message) = $np->check_messages(); |
185 | is($code, CRITICAL, "(CRITICAL) code is $STATUS_TEXT{$code}"); | 185 | is($code, CRITICAL, "(CRITICAL) code is $STATUS_TEXT{$code}"); |
186 | is($message, $messages{critical}, "(CRITICAL) message is $message"); | 186 | is($message, $messages{critical}, "(CRITICAL) message is $message"); |
187 | 187 | ||
188 | $np = Nagios::Plugin->new (usage => "dummy usage"); | 188 | $np = Nagios::Plugin->new(); |
189 | $np->add_message( WARNING, "D E F" ); | 189 | $np->add_message( WARNING, "D E F" ); |
190 | ($code, $message) = $np->check_messages(); | 190 | ($code, $message) = $np->check_messages(); |
191 | is($code, WARNING, "(WARNING) code is $STATUS_TEXT{$code}"); | 191 | is($code, WARNING, "(WARNING) code is $STATUS_TEXT{$code}"); |
192 | is($message, $messages{warning}, "(WARNING) message is $message"); | 192 | is($message, $messages{warning}, "(WARNING) message is $message"); |
193 | 193 | ||
194 | $np = Nagios::Plugin->new (usage => "dummy usage"); | 194 | $np = Nagios::Plugin->new(); |
195 | $np->add_message( WARNING, "D E F" ); | 195 | $np->add_message( WARNING, "D E F" ); |
196 | $np->add_message( OK, "G H I" ); | 196 | $np->add_message( OK, "G H I" ); |
197 | ($code, $message) = $np->check_messages(); | 197 | ($code, $message) = $np->check_messages(); |
198 | is($code, WARNING, "(WARNING, OK) code is $STATUS_TEXT{$code}"); | 198 | is($code, WARNING, "(WARNING, OK) code is $STATUS_TEXT{$code}"); |
199 | is($message, $messages{warning}, "(WARNING, OK) message is $message"); | 199 | is($message, $messages{warning}, "(WARNING, OK) message is $message"); |
200 | 200 | ||
201 | $np = Nagios::Plugin->new (usage => "dummy usage"); | 201 | $np = Nagios::Plugin->new(); |
202 | $np->add_message( OK, "G H I" ); | 202 | $np->add_message( OK, "G H I" ); |
203 | ($code, $message) = $np->check_messages(); | 203 | ($code, $message) = $np->check_messages(); |
204 | is($code, OK, "(OK) code is $STATUS_TEXT{$code}"); | 204 | is($code, OK, "(OK) code is $STATUS_TEXT{$code}"); |
@@ -206,33 +206,33 @@ is($message, $messages{ok}, "(OK) message is $message"); | |||
206 | 206 | ||
207 | 207 | ||
208 | # String codes | 208 | # String codes |
209 | $np = Nagios::Plugin->new (usage => "dummy usage"); | 209 | $np = Nagios::Plugin->new(); |
210 | $np->add_message( critical => "A B C" ); | 210 | $np->add_message( critical => "A B C" ); |
211 | $np->add_message( warning => "D E F" ); | 211 | $np->add_message( warning => "D E F" ); |
212 | ($code, $message) = $np->check_messages(); | 212 | ($code, $message) = $np->check_messages(); |
213 | is($code, CRITICAL, "(critical, warning) code is $STATUS_TEXT{$code}"); | 213 | is($code, CRITICAL, "(critical, warning) code is $STATUS_TEXT{$code}"); |
214 | is($message, $messages{critical}, "(critical, warning) message is $message"); | 214 | is($message, $messages{critical}, "(critical, warning) message is $message"); |
215 | 215 | ||
216 | $np = Nagios::Plugin->new (usage => "dummy usage"); | 216 | $np = Nagios::Plugin->new(); |
217 | $np->add_message( critical => "A B C" ); | 217 | $np->add_message( critical => "A B C" ); |
218 | ($code, $message) = $np->check_messages(); | 218 | ($code, $message) = $np->check_messages(); |
219 | is($code, CRITICAL, "(critical) code is $STATUS_TEXT{$code}"); | 219 | is($code, CRITICAL, "(critical) code is $STATUS_TEXT{$code}"); |
220 | is($message, $messages{critical}, "(critical) message is $message"); | 220 | is($message, $messages{critical}, "(critical) message is $message"); |
221 | 221 | ||
222 | $np = Nagios::Plugin->new (usage => "dummy usage"); | 222 | $np = Nagios::Plugin->new(); |
223 | $np->add_message( warning => "D E F" ); | 223 | $np->add_message( warning => "D E F" ); |
224 | ($code, $message) = $np->check_messages(); | 224 | ($code, $message) = $np->check_messages(); |
225 | is($code, WARNING, "(warning) code is $STATUS_TEXT{$code}"); | 225 | is($code, WARNING, "(warning) code is $STATUS_TEXT{$code}"); |
226 | is($message, $messages{warning}, "(warning) message is $message"); | 226 | is($message, $messages{warning}, "(warning) message is $message"); |
227 | 227 | ||
228 | $np = Nagios::Plugin->new (usage => "dummy usage"); | 228 | $np = Nagios::Plugin->new(); |
229 | $np->add_message( warning => "D E F" ); | 229 | $np->add_message( warning => "D E F" ); |
230 | $np->add_message( ok => "G H I" ); | 230 | $np->add_message( ok => "G H I" ); |
231 | ($code, $message) = $np->check_messages(); | 231 | ($code, $message) = $np->check_messages(); |
232 | is($code, WARNING, "(warning, ok) code is $STATUS_TEXT{$code}"); | 232 | is($code, WARNING, "(warning, ok) code is $STATUS_TEXT{$code}"); |
233 | is($message, $messages{warning}, "(warning, ok) message is $message"); | 233 | is($message, $messages{warning}, "(warning, ok) message is $message"); |
234 | 234 | ||
235 | $np = Nagios::Plugin->new (usage => "dummy usage"); | 235 | $np = Nagios::Plugin->new(); |
236 | $np->add_message( ok => "G H I" ); | 236 | $np->add_message( ok => "G H I" ); |
237 | ($code, $message) = $np->check_messages(); | 237 | ($code, $message) = $np->check_messages(); |
238 | is($code, OK, "(ok) code is $STATUS_TEXT{$code}"); | 238 | is($code, OK, "(ok) code is $STATUS_TEXT{$code}"); |
@@ -240,7 +240,7 @@ is($message, $messages{ok}, "(ok) message is $message"); | |||
240 | 240 | ||
241 | 241 | ||
242 | # No add_message | 242 | # No add_message |
243 | $np = Nagios::Plugin->new (usage => "dummy usage"); | 243 | $np = Nagios::Plugin->new(); |
244 | ($code, $message) = $np->check_messages(); | 244 | ($code, $message) = $np->check_messages(); |
245 | is($code, OK, "() code is $STATUS_TEXT{$code}"); | 245 | is($code, OK, "() code is $STATUS_TEXT{$code}"); |
246 | is($message, '', "() message is ''"); | 246 | is($message, '', "() message is ''"); |
@@ -250,7 +250,7 @@ is($message, '', "() message is ''"); | |||
250 | # Error conditions | 250 | # Error conditions |
251 | 251 | ||
252 | # add_message errors | 252 | # add_message errors |
253 | $np = Nagios::Plugin->new (usage => "dummy usage"); | 253 | $np = Nagios::Plugin->new(); |
254 | ok(! defined eval { $np->add_message( foobar => 'hi mum' ) }, | 254 | ok(! defined eval { $np->add_message( foobar => 'hi mum' ) }, |
255 | 'add_message dies on invalid code'); | 255 | 'add_message dies on invalid code'); |
256 | ok(! defined eval { $np->add_message( OKAY => 'hi mum' ) }, | 256 | ok(! defined eval { $np->add_message( OKAY => 'hi mum' ) }, |