summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorNathan Vonnahme <n8v@users.sourceforge.net>2006-11-15 02:11:10 +0000
committerNathan Vonnahme <n8v@users.sourceforge.net>2006-11-15 02:11:10 +0000
commit22509ac75b3ae04f35b22c87bbd85c643bb1db2b (patch)
tree8423e25fd60ca9c275aa890817b96ae9d50d168f /t
parent79b36b4d71afeb016a3b4764b6b484754323b011 (diff)
downloadmonitoring-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.t6
-rw-r--r--t/Nagios-Plugin-02.t4
-rw-r--r--t/Nagios-Plugin-03.t26
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);
11diag "\nusing Nagios::Plugin revision ". $Nagios::Plugin::VERSION . "\n" 11diag "\nusing Nagios::Plugin revision ". $Nagios::Plugin::VERSION . "\n"
12 if $ENV{TEST_VERBOSE}; 12 if $ENV{TEST_VERBOSE};
13 13
14my $p = Nagios::Plugin->new (usage => "dummy usage"); 14my $p = Nagios::Plugin->new();
15isa_ok( $p, "Nagios::Plugin"); 15isa_ok( $p, "Nagios::Plugin");
16 16
17$p->shortname("PAGESIZE"); 17$p->shortname("PAGESIZE");
18is($p->shortname, "PAGESIZE", "shortname explicitly set correctly"); 18is($p->shortname, "PAGESIZE", "shortname explicitly set correctly");
19 19
20$p = Nagios::Plugin->new (usage => "dummy usage"); 20$p = Nagios::Plugin->new();
21is($p->shortname, "NAGIOS-PLUGIN-01", "shortname should default on new"); 21is($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", () );
24is($p->shortname, "SIZE", "shortname set correctly on new"); 24is($p->shortname, "SIZE", "shortname set correctly on new");
25 25
26diag "warn if < 10, critical if > 25 " if $ENV{TEST_VERBOSE}; 26diag "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}");
16is(DEPENDENT, $ERRORS{DEPENDENT}, "DEPENDENT => $ERRORS{DEPENDENT}"); 16is(DEPENDENT, $ERRORS{DEPENDENT}, "DEPENDENT => $ERRORS{DEPENDENT}");
17 17
18my $plugin = 'TEST_PLUGIN'; 18my $plugin = 'TEST_PLUGIN';
19my $np = Nagios::Plugin->new( shortname => $plugin, usage => "dummy usage" ); 19my $np = Nagios::Plugin->new( shortname => $plugin );
20is($np->shortname, $plugin, "shortname() is $plugin"); 20is($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
152SKIP: { 152SKIP: {
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 {
10Nagios::Plugin::Functions::_fake_exit(1); 10Nagios::Plugin::Functions::_fake_exit(1);
11 11
12my $plugin = 'NP_CHECK_MESSAGES_03'; 12my $plugin = 'NP_CHECK_MESSAGES_03';
13my $np = Nagios::Plugin->new( shortname => $plugin, usage => "dummy usage" ); 13my $np = Nagios::Plugin->new( shortname => $plugin, () );
14is($np->shortname, $plugin, "shortname() is $plugin"); 14is($np->shortname, $plugin, "shortname() is $plugin");
15 15
16my ($code, $message); 16my ($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();
179is($code, CRITICAL, "(CRITICAL, WARNING) code is $STATUS_TEXT{$code}"); 179is($code, CRITICAL, "(CRITICAL, WARNING) code is $STATUS_TEXT{$code}");
180is($message, $messages{critical}, "(CRITICAL, WARNING) message is $message"); 180is($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();
185is($code, CRITICAL, "(CRITICAL) code is $STATUS_TEXT{$code}"); 185is($code, CRITICAL, "(CRITICAL) code is $STATUS_TEXT{$code}");
186is($message, $messages{critical}, "(CRITICAL) message is $message"); 186is($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();
191is($code, WARNING, "(WARNING) code is $STATUS_TEXT{$code}"); 191is($code, WARNING, "(WARNING) code is $STATUS_TEXT{$code}");
192is($message, $messages{warning}, "(WARNING) message is $message"); 192is($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();
198is($code, WARNING, "(WARNING, OK) code is $STATUS_TEXT{$code}"); 198is($code, WARNING, "(WARNING, OK) code is $STATUS_TEXT{$code}");
199is($message, $messages{warning}, "(WARNING, OK) message is $message"); 199is($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();
204is($code, OK, "(OK) code is $STATUS_TEXT{$code}"); 204is($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();
213is($code, CRITICAL, "(critical, warning) code is $STATUS_TEXT{$code}"); 213is($code, CRITICAL, "(critical, warning) code is $STATUS_TEXT{$code}");
214is($message, $messages{critical}, "(critical, warning) message is $message"); 214is($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();
219is($code, CRITICAL, "(critical) code is $STATUS_TEXT{$code}"); 219is($code, CRITICAL, "(critical) code is $STATUS_TEXT{$code}");
220is($message, $messages{critical}, "(critical) message is $message"); 220is($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();
225is($code, WARNING, "(warning) code is $STATUS_TEXT{$code}"); 225is($code, WARNING, "(warning) code is $STATUS_TEXT{$code}");
226is($message, $messages{warning}, "(warning) message is $message"); 226is($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();
232is($code, WARNING, "(warning, ok) code is $STATUS_TEXT{$code}"); 232is($code, WARNING, "(warning, ok) code is $STATUS_TEXT{$code}");
233is($message, $messages{warning}, "(warning, ok) message is $message"); 233is($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();
238is($code, OK, "(ok) code is $STATUS_TEXT{$code}"); 238is($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();
245is($code, OK, "() code is $STATUS_TEXT{$code}"); 245is($code, OK, "() code is $STATUS_TEXT{$code}");
246is($message, '', "() message is ''"); 246is($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();
254ok(! defined eval { $np->add_message( foobar => 'hi mum' ) }, 254ok(! defined eval { $np->add_message( foobar => 'hi mum' ) },
255 'add_message dies on invalid code'); 255 'add_message dies on invalid code');
256ok(! defined eval { $np->add_message( OKAY => 'hi mum' ) }, 256ok(! defined eval { $np->add_message( OKAY => 'hi mum' ) },