[Nagios-Plugin] Add new test - match on "die" error message

"Nagios Plugin Development" <[email protected]> Fri, 29 Jun 2012 03:01:23 +0000
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
 Module: Nagios-Plugin
 Branch: master
 Commit: bacb16365718f55bbb09f9d990011e3829691f16
 Author: Thomas Guyot-Sionnest <[email protected]>
   Date: Thu Jun 28 22:49:41 2012 -0400
    URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/Nagios-Plugin;a=commit;h=bacb163

Add new test - match on "die" error message

1. Add new test "class" where expected data is the error string caught
2. Add new test exposing a bug where default file used is not shown, ex:
  Invalid section 'bad_section' in config file ''

---

 t/Nagios-Plugin-Getopt-03.t          |    3 ++-
 t/npg03/expected/15_badsection_catch |    1 +
 t/npg03/input/15_badsection_catch    |    1 +
 3 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/t/Nagios-Plugin-Getopt-03.t b/t/Nagios-Plugin-Getopt-03.t
index 11443c8..560b782 100644
--- a/t/Nagios-Plugin-Getopt-03.t
+++ b/t/Nagios-Plugin-Getopt-03.t
@@ -96,7 +96,8 @@ for my $infile (glob File::Spec->catfile($tdir, 'input', $glob)) {
       eval { $ng->getopts };
       if ($@) {
         chomp $@;
-        ok($infile =~ m/_dies?$/, "$infile ($@)");
+        ok($infile =~ m/_(dies?|catch)$/, "$infile ($@)");
+        is($@, $EXPECTED{$infile}, $infile) if ($infile =~ m/_catch$/);
       }
       else { 
         is($plugin . ' ' . $ng->_cmdline, $EXPECTED{$infile}, $infile);
diff --git a/t/npg03/expected/15_badsection_catch b/t/npg03/expected/15_badsection_catch
new file mode 100644
index 0000000..7505c2b
--- /dev/null
+++ b/t/npg03/expected/15_badsection_catch
@@ -0,0 +1 @@
+Invalid section 'bad_section' in config file 't/npg03/plugins.ini'
diff --git a/t/npg03/input/15_badsection_catch b/t/npg03/input/15_badsection_catch
new file mode 100644
index 0000000..bcc026a
--- /dev/null
+++ b/t/npg03/input/15_badsection_catch
@@ -0,0 +1 @@
+check_no_section_default_file --extra-opts=bad_section


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/