| File: | t/lib/Code/Statistics/ConfigTest.pm |
| Coverage: | 100.0% |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | 1 1 1 | 0 0 0 | use strict; | ||||
| 2 | 1 1 1 | 0 0 0 | use warnings; | ||||
| 3 | |||||||
| 4 | package Code::Statistics::ConfigTest; | ||||||
| 5 | |||||||
| 6 | 1 1 1 | 0 0 0 | use lib '../..'; | ||||
| 7 | |||||||
| 8 | 1 1 1 | 0 0 0 | use parent 'Test::Class::TestGroup'; | ||||
| 9 | |||||||
| 10 | 1 1 1 | 0 0 0 | use Test::More; | ||||
| 11 | |||||||
| 12 | 1 1 1 | 0 0 0 | use Code::Statistics::Config; | ||||
| 13 | |||||||
| 14 | sub make_fixtures : Test(setup) { | ||||||
| 15 | 3 | 0 | my ( $self ) = @_; | ||||
| 16 | |||||||
| 17 | 3 | 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 | 3 | 0 | return; | ||||
| 26 | 1 1 1 | 0 0 0 | } | ||||
| 27 | |||||||
| 28 | sub overrides_basic : TestGroup(configuration overrides work if all config inputs are present and active) { | ||||||
| 29 | 1 | 0 | my ( $self ) = @_; | ||||
| 30 | |||||||
| 31 | 1 | 0 | my $config = Code::Statistics::Config->new( $self->{conf_args} )->assemble; | ||||
| 32 | |||||||
| 33 | 1 | 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 | 1 1 | 0 0 | is( $config->{$_}, $options{$_}, "$_ works" ) for keys %options; | ||||
| 44 | |||||||
| 45 | 1 | 0 | return; | ||||
| 46 | 1 1 1 | 0 0 0 | } | ||||
| 47 | |||||||
| 48 | sub overrides_no_profile : TestGroup(configuration overrides work if all no profile is given) { | ||||||
| 49 | 1 | 0 | my ( $self ) = @_; | ||||
| 50 | |||||||
| 51 | 1 | 0 | delete $self->{conf_args}{profile}; | ||||
| 52 | |||||||
| 53 | 1 | 0 | my $config = Code::Statistics::Config->new( $self->{conf_args} )->assemble; | ||||
| 54 | |||||||
| 55 | 1 | 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 | 1 1 | 0 0 | is( $config->{$_}, $options{$_}, "$_ works" ) for keys %options; | ||||
| 66 | |||||||
| 67 | 1 | 0 | return; | ||||
| 68 | 1 1 1 | 0 0 0 | } | ||||
| 69 | |||||||
| 70 | sub overrides_no_file : TestGroup(configuration overrides work if a file argument is empty) { | ||||||
| 71 | 1 | 0 | my ( $self ) = @_; | ||||
| 72 | |||||||
| 73 | 1 | 0 | $self->{conf_args}{conf_file} = ''; | ||||
| 74 | |||||||
| 75 | 1 | 0 | my $config = Code::Statistics::Config->new( $self->{conf_args} )->assemble; | ||||
| 76 | |||||||
| 77 | 1 | 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 | 1 1 | 0 0 | is( $config->{$_}, $options{$_}, "$_ works" ) for keys %options; | ||||
| 88 | |||||||
| 89 | 1 | 0 | return; | ||||
| 90 | 1 1 1 | 0 0 0 | } | ||||
| 91 | |||||||
| 92 | 1; | ||||||