diff options
Diffstat (limited to 't/format.t')
-rw-r--r-- | t/format.t | 17 |
1 files changed, 4 insertions, 13 deletions
@@ -1,25 +1,22 @@ | |||
1 | # -*- perl -*- | 1 | # -*- perl -*- |
2 | use lib qw(t lib); | 2 | use lib qw(t lib); |
3 | use strict; | 3 | use strict; |
4 | use warnings; | 4 | use warnings; |
5 | use Test::More; | 5 | use Test::More; |
6 | use autodie; | ||
7 | 6 | ||
8 | BEGIN { | 7 | BEGIN { |
9 | plan tests => 6; | 8 | plan tests => 6; |
10 | use_ok('Test::HAProxy'); | 9 | use_ok('Test::HAProxy'); |
11 | } | 10 | } |
12 | 11 | ||
13 | my $hp = new Test::HAProxy; | 12 | my $hp = new Test::HAProxy; |
14 | isa_ok($hp,'Test::HAProxy'); | 13 | isa_ok($hp,'Test::HAProxy'); |
15 | 14 | ||
16 | my $s; | 15 | my $s; |
17 | open(my $fh, '>', \$s); | 16 | $hp->write(\$s); |
18 | $hp->write($fh); | ||
19 | close $fh; | ||
20 | 17 | ||
21 | is($s, q{global | 18 | is($s, q{global |
22 | # comment | 19 | # comment |
23 | log /dev/log daemon | 20 | log /dev/log daemon |
24 | user haproxy | 21 | user haproxy |
25 | group haproxy | 22 | group haproxy |
@@ -30,15 +27,13 @@ frontend in | |||
30 | mode http | 27 | mode http |
31 | bind :::80 v4v6 | 28 | bind :::80 v4v6 |
32 | backend out | 29 | backend out |
33 | server localhost http://127.0.0.1 | 30 | server localhost http://127.0.0.1 |
34 | }, 'default write'); | 31 | }, 'default write'); |
35 | 32 | ||
36 | open($fh, '>', \$s); | 33 | $hp->write(\$s, indent => 2); |
37 | $hp->write($fh, indent => 2); | ||
38 | close $fh; | ||
39 | 34 | ||
40 | is($s, q{global | 35 | is($s, q{global |
41 | # comment | 36 | # comment |
42 | log /dev/log daemon | 37 | log /dev/log daemon |
43 | user haproxy | 38 | user haproxy |
44 | group haproxy | 39 | group haproxy |
@@ -49,15 +44,13 @@ frontend in | |||
49 | mode http | 44 | mode http |
50 | bind :::80 v4v6 | 45 | bind :::80 v4v6 |
51 | backend out | 46 | backend out |
52 | server localhost http://127.0.0.1 | 47 | server localhost http://127.0.0.1 |
53 | }, 'reindent'); | 48 | }, 'reindent'); |
54 | 49 | ||
55 | open($fh, '>', \$s); | 50 | $hp->write(\$s, indent => 2, reindent_comments => 1); |
56 | $hp->write($fh, indent => 2, reindent_comments => 1); | ||
57 | close $fh; | ||
58 | 51 | ||
59 | is($s, q{global | 52 | is($s, q{global |
60 | # comment | 53 | # comment |
61 | log /dev/log daemon | 54 | log /dev/log daemon |
62 | user haproxy | 55 | user haproxy |
63 | group haproxy | 56 | group haproxy |
@@ -68,15 +61,13 @@ frontend in | |||
68 | mode http | 61 | mode http |
69 | bind :::80 v4v6 | 62 | bind :::80 v4v6 |
70 | backend out | 63 | backend out |
71 | server localhost http://127.0.0.1 | 64 | server localhost http://127.0.0.1 |
72 | }, 'reindent comments'); | 65 | }, 'reindent comments'); |
73 | 66 | ||
74 | open($fh, '>', \$s); | 67 | $hp->write(\$s, indent => 4, tabstop => [ 10, 24 ]); |
75 | $hp->write($fh, indent => 4, tabstop => [ 10, 24 ]); | ||
76 | close $fh; | ||
77 | 68 | ||
78 | is($s, q{global | 69 | is($s, q{global |
79 | # comment | 70 | # comment |
80 | log /dev/log daemon | 71 | log /dev/log daemon |
81 | user haproxy | 72 | user haproxy |
82 | group haproxy | 73 | group haproxy |