File Coverage: t/lib/Code/Statistics/ConfigTest.pm

# File Coverage

File: | t/lib/Code/Statistics/ConfigTest.pm
Coverage: | 100.0%

line | stmt | bran | cond | sub | pod | time | code
--- | --- | --- | --- | --- | --- | --- | ---
1 | 2 2 2 |  |  | 2 |  | 0 0 0 | use strict;
2 | 2 2 2 |  |  | 2 |  | 0 0 0 | use warnings;
3 |
4 |  |  |  |  |  |  | package Code::Statistics::ConfigTest;
5 |
6 | 2 2 2 |  |  | 2 |  | 0 0 0 | use lib '../..';
7 |
8 | 2 2 2 |  |  | 2 |  | 0 15625 0 | use parent 'Test::Class::TestGroup';
9 |
10 | 2 2 2 |  |  | 2 |  | 0 0 0 | use Test::More;
11 |
12 | 2 2 2 |  |  | 2 |  | 0 0 0 | use Code::Statistics::Config;
13 |
14 |  |  |  |  |  |  | sub make_fixtures : Test(setup) {
15 | 6 |  |  | 6 |  | 0 | my ( $self ) = @_;
16 |
17 | 6 |  |  |  |  | 0 | $self->{conf_args} = {
18 |  |  |  |  |  |  | global_conf_file => 'data/config/globalcodestatrc',
19 |  |  |  |  |  |  | conf_file => 'data/config/codestatrc',
20 |  |  |  |  |  |  | command => 'collect',
21 |  |  |  |  |  |  | profile => 'test',
22 |  |  |  |  |  |  | args => { overridden_by_args => 7 },
23 |  |  |  |  |  |  | };
24 |
25 | 6 |  |  |  |  | 0 | return;
26 | 2 2 2 |  |  | 2 |  | 0 0 0 | }
27 |
28 |  |  |  |  |  |  | sub overrides_basic : TestGroup(configuration overrides work if all config inputs are present and active) {
29 | 2 |  |  |  |  | 0 | my ( $self ) = @_;
30 |
31 | 2 |  |  |  |  | 0 | my $config = Code::Statistics::Config->new( $self->{conf_args} )->assemble;
32 |
33 | 2 |  |  |  |  | 0 | my %options = (
34 |  |  |  |  |  |  | global_setting => 1,
35 |  |  |  |  |  |  | overridden_by_command => 2,
36 |  |  |  |  |  |  | overridden_by_profile => 3,
37 |  |  |  |  |  |  | overridden_by_local => 4,
38 |  |  |  |  |  |  | overridden_by_local_command => 5,
39 |  |  |  |  |  |  | overridden_by_local_profile => 6,
40 |  |  |  |  |  |  | overridden_by_args => 7,
41 |  |  |  |  |  |  | );
42 |
43 | 2 2 |  |  |  |  | 0 0 | is( $config->{$_}, $options{$_}, "$_ works" ) for keys %options;
44 |
45 | 2 |  |  |  |  | 0 | return;
46 | 2 2 2 |  |  | 2 |  | 0 0 0 | }
47 |
48 |  |  |  |  |  |  | sub overrides_no_profile : TestGroup(configuration overrides work if all no profile is given) {
49 | 2 |  |  |  |  | 0 | my ( $self ) = @_;
50 |
51 | 2 |  |  |  |  | 0 | delete $self->{conf_args}{profile};
52 |
53 | 2 |  |  |  |  | 0 | my $config = Code::Statistics::Config->new( $self->{conf_args} )->assemble;
54 |
55 | 2 |  |  |  |  | 0 | my %options = (
56 |  |  |  |  |  |  | global_setting => 1,
57 |  |  |  |  |  |  | overridden_by_command => 2,
58 |  |  |  |  |  |  | overridden_by_profile => 2,
59 |  |  |  |  |  |  | overridden_by_local => 4,
60 |  |  |  |  |  |  | overridden_by_local_command => 5,
61 |  |  |  |  |  |  | overridden_by_local_profile => 5,
62 |  |  |  |  |  |  | overridden_by_args => 7,
63 |  |  |  |  |  |  | );
64 |
65 | 2 2 |  |  |  |  | 0 0 | is( $config->{$_}, $options{$_}, "$_ works" ) for keys %options;
66 |
67 | 2 |  |  |  |  | 0 | return;
68 | 2 2 2 |  |  | 2 |  | 0 0 0 | }
69 |
70 |  |  |  |  |  |  | sub overrides_no_file : TestGroup(configuration overrides work if a file argument is empty) {
71 | 2 |  |  |  |  | 0 | my ( $self ) = @_;
72 |
73 | 2 |  |  |  |  | 0 | $self->{conf_args}{conf_file} = '';
74 |
75 | 2 |  |  |  |  | 0 | my $config = Code::Statistics::Config->new( $self->{conf_args} )->assemble;
76 |
77 | 2 |  |  |  |  | 0 | my %options = (
78 |  |  |  |  |  |  | global_setting => 1,
79 |  |  |  |  |  |  | overridden_by_command => 2,
80 |  |  |  |  |  |  | overridden_by_profile => 3,
81 |  |  |  |  |  |  | overridden_by_local => 3,
82 |  |  |  |  |  |  | overridden_by_local_command => 3,
83 |  |  |  |  |  |  | overridden_by_local_profile => 3,
84 |  |  |  |  |  |  | overridden_by_args => 7,
85 |  |  |  |  |  |  | );
86 |
87 | 2 2 |  |  |  |  | 0 0 | is( $config->{$_}, $options{$_}, "$_ works" ) for keys %options;
88 |
89 | 2 |  |  |  |  | 0 | return;
90 | 2 2 2 |  |  | 2 |  | 0 0 0 | }
91 |
92 |  |  |  |  |  |  | 1;