File: 12-loader-file.t

package info (click to toggle)
libconfig-zomg-perl 1.000000-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 264 kB
  • sloc: perl: 352; makefile: 9; sh: 4
file content (78 lines) | stat: -rw-r--r-- 1,922 bytes parent folder | download | duplicates (2)
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
use strict;
use warnings;

use Test::More;
use Test::Deep;
use Test::Warn;

use Config::ZOMG;

sub has_Config_General {
    return eval "require Config::General;";
}

{
    my $config = Config::ZOMG->new(
        file => "t/assets/some_random_file.pl"
    );

    ok($config->load);
    is($config->load->{'Controller::Foo'}->{foo},       'bar');
    is($config->load->{'Model::Baz'}->{qux},            'xyzzy');
    is($config->load->{'view'},                         'View::TT');
    is($config->load->{'random'},                        1);
}

SKIP: {
    skip 'Config::General required' unless has_Config_General;
    my $config;

    $config = Config::ZOMG->new(
        path => "t/assets/order/../",
        name => "dotdot",
    );
    ok($config->load, 'Load a config from a directory path ending with ../');
    cmp_deeply( $config->load, {
        test => 'paths ending with ../',
    } );

    $config = Config::ZOMG->new(
        path => "t/assets/order/xyzzy.cnf"
    );
    cmp_deeply( $config->load, {
        cnf => 1,
        last => 'local_cnf',
        local_cnf => 1,
    } );

    $config = Config::ZOMG->new(
        file => "t/assets/order/xyzzy.cnf"
    );
    cmp_deeply( $config->load, {
        cnf => 1,
        last => 'cnf',
    } );

    $config = Config::ZOMG->new(
        path => "t/assets/order/xyzzy.cnf",
        no_local => 1
    );
    cmp_deeply( $config->load, {
        cnf => 1,
        last => 'cnf',
    } );

    warning_is { $config = Config::ZOMG->new( file => "t/assets/order/xyzzy.cnf", ) } undef;

    warning_is { $config = Config::ZOMG->new( file => "t/assets/order/xyzzy.cnf", no_06_warning => 1 ) } '';

    warning_is { $config = Config::ZOMG->new( file => "t/assets/order/xyzzy.cnf", quiet_deprecation => 1 ) } '';

    $config = Config::ZOMG->new(
        file => "t/assets/file-does-not-exist.cnf"
    );
    cmp_deeply( $config->load, {
    } );
}

done_testing;