From 0e41613e9f547ab97365329572555936e84f77b2 Mon Sep 17 00:00:00 2001 From: Gavin Carr Date: Thu, 8 Feb 2007 05:18:06 +0000 Subject: Add initial --default-opts implementation to Nagios::Plugin::Getopt (II). git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1617 f882894a-f735-0410-b71e-b25c423dba1c --- t/npg03/README | 13 +++++++++++++ t/npg03/expected/00_basic | 1 + t/npg03/expected/01_override1 | 1 + t/npg03/expected/02_override2 | 1 + t/npg03/expected/05_singlechar1 | 1 + t/npg03/expected/06_singlechar2 | 1 + t/npg03/expected/07_singlechar3 | 1 + t/npg03/expected/09_funnystuff | 1 + t/npg03/expected/12_nosection_implicit | 1 + t/npg03/input/00_basic | 1 + t/npg03/input/01_override1 | 1 + t/npg03/input/02_override2 | 1 + t/npg03/input/05_singlechar1 | 1 + t/npg03/input/06_singlechar2 | 1 + t/npg03/input/07_singlechar3 | 1 + t/npg03/input/09_funnystuff | 1 + t/npg03/input/12_nosection_implicit | 1 + t/npg03/input/13_nosection_explicit_dies | 1 + t/npg03/input/14_badsection_dies | 1 + t/npg03/plugins.cfg | 21 +++++++++++++++++++++ 20 files changed, 52 insertions(+) create mode 100644 t/npg03/README create mode 100644 t/npg03/expected/00_basic create mode 100644 t/npg03/expected/01_override1 create mode 100644 t/npg03/expected/02_override2 create mode 100644 t/npg03/expected/05_singlechar1 create mode 100644 t/npg03/expected/06_singlechar2 create mode 100644 t/npg03/expected/07_singlechar3 create mode 100644 t/npg03/expected/09_funnystuff create mode 100644 t/npg03/expected/12_nosection_implicit create mode 100644 t/npg03/input/00_basic create mode 100644 t/npg03/input/01_override1 create mode 100644 t/npg03/input/02_override2 create mode 100644 t/npg03/input/05_singlechar1 create mode 100644 t/npg03/input/06_singlechar2 create mode 100644 t/npg03/input/07_singlechar3 create mode 100644 t/npg03/input/09_funnystuff create mode 100644 t/npg03/input/12_nosection_implicit create mode 100644 t/npg03/input/13_nosection_explicit_dies create mode 100644 t/npg03/input/14_badsection_dies create mode 100644 t/npg03/plugins.cfg (limited to 't/npg03') diff --git a/t/npg03/README b/t/npg03/README new file mode 100644 index 0000000..a19f263 --- /dev/null +++ b/t/npg03/README @@ -0,0 +1,13 @@ +Nagios-Plugin-Getopt-03.t automatically tests all cases defined in the 'input' directory +and expects the output to match the corresponding file in the 'expected' directory. To +define a new test case, just create a new file in the 'input' directory containing the +input command line, and a corresponding file in the 'expected' directory containing +what you think the expanded command line should be. Note that this expansion is normalised +as follows: + +- command line arguments are reported in alphabetical order +- extraneous white space is removed + +Also, if you use a completely new argument than those defined in Nagios-Plugin-Getopt-03.t +you will need to define it there as well. + diff --git a/t/npg03/expected/00_basic b/t/npg03/expected/00_basic new file mode 100644 index 0000000..9707dbd --- /dev/null +++ b/t/npg03/expected/00_basic @@ -0,0 +1 @@ +check_mysql -H localhost -S --critical=15 --password=secret --username=altinity --warning=10 diff --git a/t/npg03/expected/01_override1 b/t/npg03/expected/01_override1 new file mode 100644 index 0000000..8288914 --- /dev/null +++ b/t/npg03/expected/01_override1 @@ -0,0 +1 @@ +check_mysql --critical=15 --username=admin --warning=5 diff --git a/t/npg03/expected/02_override2 b/t/npg03/expected/02_override2 new file mode 100644 index 0000000..7946308 --- /dev/null +++ b/t/npg03/expected/02_override2 @@ -0,0 +1 @@ +check_mysql --password=secret --username=admin diff --git a/t/npg03/expected/05_singlechar1 b/t/npg03/expected/05_singlechar1 new file mode 100644 index 0000000..13a3f9b --- /dev/null +++ b/t/npg03/expected/05_singlechar1 @@ -0,0 +1 @@ +check_disk -p /home diff --git a/t/npg03/expected/06_singlechar2 b/t/npg03/expected/06_singlechar2 new file mode 100644 index 0000000..8f9df5e --- /dev/null +++ b/t/npg03/expected/06_singlechar2 @@ -0,0 +1 @@ +check_disk -p /var diff --git a/t/npg03/expected/07_singlechar3 b/t/npg03/expected/07_singlechar3 new file mode 100644 index 0000000..f4e6ed7 --- /dev/null +++ b/t/npg03/expected/07_singlechar3 @@ -0,0 +1 @@ +check_disk -p /home -p /users diff --git a/t/npg03/expected/09_funnystuff b/t/npg03/expected/09_funnystuff new file mode 100644 index 0000000..6d510b8 --- /dev/null +++ b/t/npg03/expected/09_funnystuff @@ -0,0 +1 @@ +check_disk --expect=" space in front" -p "" --username="Ton Voon" diff --git a/t/npg03/expected/12_nosection_implicit b/t/npg03/expected/12_nosection_implicit new file mode 100644 index 0000000..7bb6136 --- /dev/null +++ b/t/npg03/expected/12_nosection_implicit @@ -0,0 +1 @@ +check_no_section -H localhost diff --git a/t/npg03/input/00_basic b/t/npg03/input/00_basic new file mode 100644 index 0000000..4c16788 --- /dev/null +++ b/t/npg03/input/00_basic @@ -0,0 +1 @@ +check_mysql -S --default-opts= --default-opts=more_options -H localhost diff --git a/t/npg03/input/01_override1 b/t/npg03/input/01_override1 new file mode 100644 index 0000000..9e051e9 --- /dev/null +++ b/t/npg03/input/01_override1 @@ -0,0 +1 @@ +check_mysql --username=admin --default-opts=more_options --warning=5 diff --git a/t/npg03/input/02_override2 b/t/npg03/input/02_override2 new file mode 100644 index 0000000..ceabe55 --- /dev/null +++ b/t/npg03/input/02_override2 @@ -0,0 +1 @@ +check_mysql --default-opts= -u admin diff --git a/t/npg03/input/05_singlechar1 b/t/npg03/input/05_singlechar1 new file mode 100644 index 0000000..1edb8bf --- /dev/null +++ b/t/npg03/input/05_singlechar1 @@ -0,0 +1 @@ +check_disk --default-opts= -p /home diff --git a/t/npg03/input/06_singlechar2 b/t/npg03/input/06_singlechar2 new file mode 100644 index 0000000..24965c7 --- /dev/null +++ b/t/npg03/input/06_singlechar2 @@ -0,0 +1 @@ +check_disk --default-opts=check_2_disks diff --git a/t/npg03/input/07_singlechar3 b/t/npg03/input/07_singlechar3 new file mode 100644 index 0000000..0abc70f --- /dev/null +++ b/t/npg03/input/07_singlechar3 @@ -0,0 +1 @@ +check_disk --default-opts= -p /home -p /users diff --git a/t/npg03/input/09_funnystuff b/t/npg03/input/09_funnystuff new file mode 100644 index 0000000..c2d6160 --- /dev/null +++ b/t/npg03/input/09_funnystuff @@ -0,0 +1 @@ +check_disk --default-opts=funny_stuff diff --git a/t/npg03/input/12_nosection_implicit b/t/npg03/input/12_nosection_implicit new file mode 100644 index 0000000..7bb6136 --- /dev/null +++ b/t/npg03/input/12_nosection_implicit @@ -0,0 +1 @@ +check_no_section -H localhost diff --git a/t/npg03/input/13_nosection_explicit_dies b/t/npg03/input/13_nosection_explicit_dies new file mode 100644 index 0000000..90aab51 --- /dev/null +++ b/t/npg03/input/13_nosection_explicit_dies @@ -0,0 +1 @@ +check_no_section --default-opts= -H localhost diff --git a/t/npg03/input/14_badsection_dies b/t/npg03/input/14_badsection_dies new file mode 100644 index 0000000..70815a9 --- /dev/null +++ b/t/npg03/input/14_badsection_dies @@ -0,0 +1 @@ +check_no_section --default-opts=bad_section diff --git a/t/npg03/plugins.cfg b/t/npg03/plugins.cfg new file mode 100644 index 0000000..f893a21 --- /dev/null +++ b/t/npg03/plugins.cfg @@ -0,0 +1,21 @@ +[check_mysql] +username=tonvoon +password=secret + +[more_options] +username=altinity +warning=10 +critical=15 + +[check_disk] +p=/tmp + +[check_2_disks] +p=/tmp +p=/var + +[funny_stuff] +username="Ton Voon" +p= +expect=" space in front" + -- cgit v1.2.3-74-g34f1