summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorTon Voon <tonvoon@macbook.local>2008-12-02 16:53:56 (GMT)
committerTon Voon <tonvoon@macbook.local>2008-12-02 16:53:56 (GMT)
commit0907cdbca2ebcb775a0bbcae639e378e440cd738 (patch)
tree558bbb79f3c83fb150f689e71a38b251b17d0ba9 /t
parentc261abc4eacd49314ab18782ac8158bf9f2dbf5d (diff)
downloadmonitoring-plugin-perl-0907cdbca2ebcb775a0bbcae639e378e440cd738.tar.gz
Added clean_label, like rrdlabel, but without truncation
Diffstat (limited to 't')
-rw-r--r--t/Nagios-Plugin-Performance.t16
1 files changed, 9 insertions, 7 deletions
diff --git a/t/Nagios-Plugin-Performance.t b/t/Nagios-Plugin-Performance.t
index fa36ce0..ceb82c5 100644
--- a/t/Nagios-Plugin-Performance.t
+++ b/t/Nagios-Plugin-Performance.t
@@ -1,6 +1,6 @@
1 1
2use strict; 2use strict;
3use Test::More tests => 123; 3use Test::More;
4BEGIN { use_ok('Nagios::Plugin::Performance') }; 4BEGIN { use_ok('Nagios::Plugin::Performance') };
5 5
6diag "\nusing Nagios::Plugin::Performance revision ". $Nagios::Plugin::Performance::VERSION . "\n" if $ENV{TEST_VERBOSE}; 6diag "\nusing Nagios::Plugin::Performance revision ". $Nagios::Plugin::Performance::VERSION . "\n" if $ENV{TEST_VERBOSE};
@@ -11,20 +11,20 @@ Nagios::Plugin::Functions::_fake_exit(1);
11my (@p, $p); 11my (@p, $p);
12my @test = ( 12my @test = (
13 { 13 {
14 perfoutput => "/=382MB;15264;15269;0;32768", label => '/', rrdlabel => 'root', value => 382, uom => 'MB', warning => 15264, critical => 15269, min => 0, max => 32768, 14 perfoutput => "/=382MB;15264;15269;0;32768", label => '/', rrdlabel => 'root', value => 382, uom => 'MB', warning => 15264, critical => 15269, min => 0, max => 32768, clean_label => "root",
15 }, { 15 }, {
16 perfoutput => "/var=218MB;9443;9448", label => '/var', rrdlabel => 'var', value => '218', uom => 'MB', warning => 9443, critical => 9448, min => undef, max => undef, 16 perfoutput => "/var=218MB;9443;9448", label => '/var', rrdlabel => 'var', value => '218', uom => 'MB', warning => 9443, critical => 9448, min => undef, max => undef, clean_label => "var",
17 }, {
18 perfoutput => '/var/long@:-/filesystem/name/and/bad/chars=218MB;9443;9448', label => '/var/long@:-/filesystem/name/and/bad/chars', rrdlabel => 'var_long____filesys', value => '218', uom => 'MB', warning => 9443, critical => 9448, min => undef, max => undef, clean_label => 'var_long____filesystem_name_and_bad_chars',
17 }, 19 },
18); 20);
19 21
22plan tests => (8 * scalar @test) + 94;
23
20# Round-trip tests 24# Round-trip tests
21for my $t (@test) { 25for my $t (@test) {
22 # Parse to components 26 # Parse to components
23 ($p) = Nagios::Plugin::Performance->parse_perfstring($t->{perfoutput}); 27 ($p) = Nagios::Plugin::Performance->parse_perfstring($t->{perfoutput});
24 for (sort keys %$t) {
25 next if m/^perfoutput$/;
26 is($p->$_(), $t->{$_}, "$_ okay (" . (defined $t->{$_} ? $t->{$_} : 'undef') . ")");
27 }
28 28
29 # Construct from components 29 # Construct from components
30 my @construct = qw(label value uom warning critical min max); 30 my @construct = qw(label value uom warning critical min max);
@@ -33,6 +33,8 @@ for my $t (@test) {
33 # Check threshold accessor 33 # Check threshold accessor
34 is($p->threshold->warning->end, $t->{warning}, "threshold warning okay ($t->{warning})"); 34 is($p->threshold->warning->end, $t->{warning}, "threshold warning okay ($t->{warning})");
35 is($p->threshold->critical->end, $t->{critical}, "threshold critical okay ($t->{critical})"); 35 is($p->threshold->critical->end, $t->{critical}, "threshold critical okay ($t->{critical})");
36 is($p->rrdlabel, $t->{rrdlabel}, "rrdlabel okay");
37 is($p->clean_label, $t->{clean_label}, "clean_label okay" );
36 38
37 # Construct using threshold 39 # Construct using threshold
38 @construct = qw(label value uom min max); 40 @construct = qw(label value uom min max);