Config-Wild

 view release on metacpan or  search on metacpan

t/Config-Wild.t  view on Meta::CPAN

#!perl

use Test::More;
use Test::Fatal;

BEGIN { use_ok( 'Config::Wild' ) }

my $data_dir = 't/data/cfgs';

subtest autoload => sub {

    my $cfg = Config::Wild->new( "$data_dir/test.cnf" );

    is( $cfg->foo, 'ok', 'autoload' );
};

subtest blanks => sub {

    my $cfg = Config::Wild->new( "$data_dir/blanks.cnf" );

    is( $cfg->get( 'foo' ), 'bar',  'trailing blanks' );
    is( $cfg->get( 'too' ), 'good', 'leading blanks' );

};

subtest variables => sub {

    my $cfg = Config::Wild->new( "$data_dir/vars.cnf" );

    is( $cfg->get( 'twig' ), 'here/there', 'internal vars' );

    local $ENV{CWTEST} = 'not now';

    is( $cfg->get( 'entvar' ), 'not now or then', 'env vars' );

    is( $cfg->get( 'bothvarenv' ), 'not now or where', 'both vars (env)' );

    is( $cfg->get( 'bothvarint' ), 'here or not', 'both vars (internal)' );

    is( $cfg->get( 'nest3' ), '0/1/2/3', 'nested internal' );

    is( $cfg->get( 'enest2' ), 'not now/or then/or how',
        'nested internal/env' );

    done_testing;


};

subtest non_existent_expanded_variables => sub {

    my $cfg = Config::Wild->new( "$data_dir/vars.cnf" );

    is( $cfg->get( 'entvar' ), ' or then', 'missing environment variable' );

    $cfg->delete( 'root' );

    is( $cfg->get( 'twig' ), '/there', 'missing Config::Wild variable' );

    done_testing;
};

subtest wildcard => sub {



( run in 0.727 second using v1.01-cache-2.11-cpan-54e63673c56 )