diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-05-25 09:43:38 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-05-25 19:58:35 +0300 |
commit | 585a5a925342c357d46fbad273bfafc03bc33dcd (patch) | |
tree | 0aa81c8e85543ebaa25ef88292bb318ac4294e04 /t/lint.t | |
parent | edfeb103b85e10aa9e6825d3b92c5888fb4dea94 (diff) | |
download | config-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')
-rw-r--r-- | t/lint.t | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/t/lint.t b/t/lint.t new file mode 100644 index 0000000..aa92fd1 --- /dev/null +++ b/t/lint.t | |||
@@ -0,0 +1,33 @@ | |||
1 | # -*- perl -*- | ||
2 | use lib qw(t lib); | ||
3 | use strict; | ||
4 | use warnings; | ||
5 | use Test::More; | ||
6 | |||
7 | BEGIN { | ||
8 | plan tests => 7; | ||
9 | use_ok('Test::HAProxy'); | ||
10 | } | ||
11 | |||
12 | my $hp = new Test::HAProxy; | ||
13 | isa_ok($hp,'Test::HAProxy'); | ||
14 | |||
15 | ok($hp->lint, 'haproxy -c -f'); | ||
16 | |||
17 | $hp->lint(0); | ||
18 | ok(!$hp->lint); | ||
19 | |||
20 | $hp->lint(1); | ||
21 | ok($hp->lint, 'haproxy -c -f'); | ||
22 | |||
23 | $hp->lint(enable => 0); | ||
24 | ok(!$hp->lint); | ||
25 | |||
26 | $hp->lint(enable => 1, command => '/usr/local/bin/haproxy -c -f'); | ||
27 | ok($hp->lint, '/usr/local/bin/haproxy -c -f'); | ||
28 | |||
29 | __DATA__ | ||
30 | global | ||
31 | log /dev/log daemon | ||
32 | user haproxy | ||
33 | group haproxy | ||