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
|
### Log::Message::Config test suite ###
BEGIN {
if( $ENV{PERL_CORE} ) {
chdir '../lib/Log/Message' if -d '../lib/Log/Message';
unshift @INC, '../../..';
}
}
BEGIN { chdir 't' if -d 't' }
use strict;
use lib qw[../lib conf];
use Test::More tests => 6;
use File::Spec;
use File::Basename qw[dirname];
use_ok( 'Log::Message::Config' ) or diag "Config.pm not found. Dying", die;
use_ok( 'Log::Message' ) or diag "Module.pm not found. Dying", die;
{
my $default = {
private => undef,
verbose => 1,
tag => 'NONE',
level => 'log',
remove => 0,
chrono => 1,
};
my $log = Log::Message->new();
is_deeply( $default, $log->{CONFIG}, q[Config creation from default] );
}
{
my $config = {
private => 1,
verbose => 1,
tag => 'TAG',
level => 'carp',
remove => 0,
chrono => 1,
};
my $log = Log::Message->new( %$config );
is_deeply( $config, $log->{CONFIG}, q[Config creation from options] );
}
{
my $file = {
private => 1,
verbose => 0,
tag => 'SOME TAG',
level => 'carp',
remove => 1,
chrono => 0,
};
my $log = Log::Message->new(
config => File::Spec->catfile( qw|conf config_file| )
);
is_deeply( $file, $log->{CONFIG}, q[Config creation from file] );
}
{
my $mixed = {
private => 1,
verbose => 0,
remove => 1,
chrono => 0,
tag => 'MIXED',
level => 'die',
};
my $log = Log::Message->new(
config => File::Spec->catfile( qw|conf config_file| ),
tag => 'MIXED',
level => 'die',
);
is_deeply( $mixed, $log->{CONFIG}, q[Config creation from file & options] );
}
|