From c128d293b015291c5e45637d9e3d5b1e1fb36c12 Mon Sep 17 00:00:00 2001 From: Thomas Guyot-Sionnest Date: Wed, 10 Mar 2010 01:54:06 -0500 Subject: shortname enhancement This patch makes shortname use the defined plugin's name if set, otherwise the normal method should prevail. To do so I had to generate shortname during np initialization instead of at use time. --- t/Nagios-Plugin-01.t | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/Nagios-Plugin-01.t b/t/Nagios-Plugin-01.t index 3ada472..947a704 100644 --- a/t/Nagios-Plugin-01.t +++ b/t/Nagios-Plugin-01.t @@ -1,7 +1,7 @@ # Nagios::Plugin original test cases use strict; -use Test::More tests => 13; +use Test::More tests => 15; BEGIN { use_ok('Nagios::Plugin') }; @@ -23,6 +23,12 @@ is($p->shortname, "NAGIOS-PLUGIN-01", "shortname should default on new"); $p = Nagios::Plugin->new( shortname => "SIZE", () ); is($p->shortname, "SIZE", "shortname set correctly on new"); +$p = Nagios::Plugin->new( plugin => "check_stuff", () ); +is($p->shortname, "STUFF", "shortname uses plugin name as default"); + +$p = Nagios::Plugin->new( shortname => "SIZE", plugin => "check_stuff", () ); +is($p->shortname, "SIZE", "shortname is not overriden by default"); + diag "warn if < 10, critical if > 25 " if $ENV{TEST_VERBOSE}; my $t = $p->set_thresholds( warning => "10:25", critical => "~:25" ); -- cgit v1.2.3-74-g34f1