summaryrefslogtreecommitdiffabout
path: root/t/format.t
blob: 06b9884bde34ca28e4e7dd215aace15f43961d03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- perl -*-
use lib qw(t lib);
use strict;
use warnings;
use Test::More;
use autodie;

BEGIN {
    plan tests => 6; 
    use_ok('Test::HAProxy');
}

my $hp = new Test::HAProxy;
isa_ok($hp,'Test::HAProxy');

my $s;
open(my $fh, '>', \$s);
$hp->write($fh);
close $fh;

is($s, q{global
# comment
    log /dev/log daemon
    user haproxy
    group haproxy
defaults
    log global
    mode http
frontend in
    mode http
    bind :::80 v4v6
backend out
    server localhost http://127.0.0.1
}, 'default write');

open($fh, '>', \$s);
$hp->write($fh, indent => 2);
close $fh;

is($s, q{global
# comment
  log /dev/log daemon
  user haproxy
  group haproxy
defaults
  log global
  mode http
frontend in
  mode http
  bind :::80 v4v6
backend out
  server localhost http://127.0.0.1
}, 'reindent');

open($fh, '>', \$s);
$hp->write($fh, indent => 2, reindent_comments => 1);
close $fh;

is($s, q{global
  # comment
  log /dev/log daemon
  user haproxy
  group haproxy
defaults
  log global
  mode http
frontend in
  mode http
  bind :::80 v4v6
backend out
  server localhost http://127.0.0.1
}, 'reindent comments');

open($fh, '>', \$s);
$hp->write($fh, indent => 4, tabstop => [ 10, 24 ]);
close $fh;

is($s, q{global
# comment
    log   /dev/log      daemon
    user  haproxy
    group haproxy
defaults
    log   global
    mode  http
frontend  in
    mode  http
    bind  :::80         v4v6
backend   out
    server localhost    http://127.0.0.1
}, 'tabstops');

__DATA__
global
# comment
    log /dev/log daemon
    user haproxy
    group haproxy
defaults
    log global
    mode http
frontend in
    mode http
    bind :::80 v4v6
backend out
    server localhost http://127.0.0.1

Return to:

Send suggestions and report system problems to the System administrator.