summaryrefslogtreecommitdiffabout
path: root/t/lint.t
authorSergey Poznyakoff <gray@gnu.org>2019-05-25 06:43:38 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-05-25 16:58:35 (GMT)
commit585a5a925342c357d46fbad273bfafc03bc33dcd (patch) (side-by-side diff)
tree0aa81c8e85543ebaa25ef88292bb318ac4294e04 /t/lint.t
parentedfeb103b85e10aa9e6825d3b92c5888fb4dea94 (diff)
downloadconfig-haproxy-585a5a925342c357d46fbad273bfafc03bc33dcd.tar.gz
config-haproxy-585a5a925342c357d46fbad273bfafc03bc33dcd.tar.bz2
Check configuration file syntax before saving it
* Makefile.PL: Require IPC::Cmd * lib/Config/HAProxy.pm (lint): New method. (save): Call linter prior to saving. Take optional dry_run keyword as argument. * t/lint.t: New file.
Diffstat (limited to 't/lint.t') (more/less context) (ignore whitespace changes)
-rw-r--r--t/lint.t33
1 files changed, 33 insertions, 0 deletions
diff --git a/t/lint.t b/t/lint.t
new file mode 100644
index 0000000..aa92fd1
--- a/dev/null
+++ b/t/lint.t
@@ -0,0 +1,33 @@
+# -*- perl -*-
+use lib qw(t lib);
+use strict;
+use warnings;
+use Test::More;
+
+BEGIN {
+ plan tests => 7;
+ use_ok('Test::HAProxy');
+}
+
+my $hp = new Test::HAProxy;
+isa_ok($hp,'Test::HAProxy');
+
+ok($hp->lint, 'haproxy -c -f');
+
+$hp->lint(0);
+ok(!$hp->lint);
+
+$hp->lint(1);
+ok($hp->lint, 'haproxy -c -f');
+
+$hp->lint(enable => 0);
+ok(!$hp->lint);
+
+$hp->lint(enable => 1, command => '/usr/local/bin/haproxy -c -f');
+ok($hp->lint, '/usr/local/bin/haproxy -c -f');
+
+__DATA__
+global
+ log /dev/log daemon
+ user haproxy
+ group haproxy

Return to:

Send suggestions and report system problems to the System administrator.