diff options
Diffstat (limited to 't/Nagios-Plugin-03.t')
-rw-r--r-- | t/Nagios-Plugin-03.t | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/t/Nagios-Plugin-03.t b/t/Nagios-Plugin-03.t index 0366156..0b7b8af 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 ); | 13 | my $np = Nagios::Plugin->new( shortname => $plugin, usage => "dummy usage" ); |
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; | 175 | $np = Nagios::Plugin->new (usage => "dummy usage"); |
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; | 182 | $np = Nagios::Plugin->new (usage => "dummy usage"); |
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; | 188 | $np = Nagios::Plugin->new (usage => "dummy usage"); |
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; | 194 | $np = Nagios::Plugin->new (usage => "dummy usage"); |
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; | 201 | $np = Nagios::Plugin->new (usage => "dummy usage"); |
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; | 209 | $np = Nagios::Plugin->new (usage => "dummy usage"); |
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; | 216 | $np = Nagios::Plugin->new (usage => "dummy usage"); |
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; | 222 | $np = Nagios::Plugin->new (usage => "dummy usage"); |
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; | 228 | $np = Nagios::Plugin->new (usage => "dummy usage"); |
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; | 235 | $np = Nagios::Plugin->new (usage => "dummy usage"); |
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; | 243 | $np = Nagios::Plugin->new (usage => "dummy usage"); |
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; | 253 | $np = Nagios::Plugin->new (usage => "dummy usage"); |
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' ) }, |