summaryrefslogtreecommitdiff
path: root/t/format.t
blob: 2d124fce42d1c77d440e439cac1e5497cba19270 (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
# -*- perl -*-
use lib qw(t lib);
use strict;
use warnings;
use Test::More;

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

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

my $s;
$hp->write(\$s);

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');

$hp->write(\$s, indent => 2);

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');

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

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');

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

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.