File: 100-config.t

package info (click to toggle)
liblog-handler-perl 0.45-1%2Blenny1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 392 kB
  • ctags: 145
  • sloc: perl: 2,017; makefile: 39
file content (53 lines) | stat: -rw-r--r-- 1,362 bytes parent folder | download
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
use strict;
use warnings;
use Test::More tests => 8;
use Log::Handler;

my %config = (
    file => {
        default => {
            newline        => 1,
            timeformat     => '%b %d %H:%M:%S',
            mode           => 'excl',
            message_layout => '%T %H[%P] [%L] %S: %m',
            debug_mode     => 2,
            fileopen       => 0,
        },
        common => {
            filename => 'foo',
            maxlevel => 'info',
            minlevel => 'info',
            newline  => 0,
        }
    }
);

my $log = Log::Handler->new();
$log->config(config => \%config);

my $options_handler = shift @{$log->{levels}->{INFO}};
my $options_file    = $options_handler->{output};

my %compare_file = (
    filename => 'foo',
    fileopen => 0,
);

my %compare_handler = (
    newline         => 0,
    timeformat      => '%b %d %H:%M:%S',
    message_layout  => '%T %H[%P] [%L] %S: %m',
    debug_mode      => 2,
    maxlevel        => 6,
    minlevel        => 6,
);

while (my ($k, $v) = each %compare_file) {
    my $ret = exists $options_file->{$k} && $options_file->{$k} eq $v;
    ok($ret, "checking option $k ($v:$options_file->{$k})");
}

while (my ($k, $v) = each %compare_handler) {
    my $ret = exists $options_handler->{$k} && $options_handler->{$k} eq $v;
    ok($ret, "checking option $k ($v:$options_handler->{$k})");
}