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
|
use strict;
use warnings;
use Test::More;
use File::Spec::Functions qw(catfile);
my $class = 'CPAN::Mini::Inject';
subtest sanity => sub {
use_ok $class or BAIL_OUT( "$class did not compile: $@" );
};
subtest 'no loadcfg' => sub {
my $mcpi = $class->new;
isa_ok $mcpi, $class;
can_ok $mcpi, 'parsecfg';
my $file = catfile qw(t .mcpani config);
ok -e $file, "file <$file> exists";
$mcpi->parsecfg( $file );
ok exists $mcpi->{config}, 'config key exists';
can_ok $mcpi, 'config';
isa_ok $mcpi->config, ref {}, 'config returns a hash ref';
is $mcpi->config->{local}, 't/local/CPAN', 'value for local matches';
is $mcpi->config->{remote}, 'http://localhost:11027', 'value for remote matches';
is $mcpi->config->{repository}, 't/local/MYCPAN', 'value for repository matches';
};
subtest 'loadcfg' => sub {
my $mcpi = $class->new;
isa_ok $mcpi, $class;
can_ok $mcpi, 'loadcfg';
my $file = catfile qw(t .mcpani config);
ok -e $file, "config file <$file> exists";
$mcpi->loadcfg( $file );
$mcpi->parsecfg;
ok exists $mcpi->{config}, 'config key exists';
can_ok $mcpi, 'config';
isa_ok $mcpi->config, ref {}, 'config returns a hash ref';
is $mcpi->config->{local}, 't/local/CPAN', 'value for local matches';
is $mcpi->config->{remote}, 'http://localhost:11027', 'value for remote matches';
is $mcpi->config->{repository}, 't/local/MYCPAN', 'value for repository matches';
};
subtest 'whitespace' => sub {
my $mcpi = $class->new;
isa_ok $mcpi, $class;
my $file = catfile qw(t .mcpani config_with_whitespaces);
ok -e $file, "file <$file> exists";
$mcpi->parsecfg( $file );
is $mcpi->config->{local}, 't/local/CPAN', 'value for local matches';
is $mcpi->config->{remote}, 'http://localhost:11027', 'value for remote matches';
is $mcpi->config->{repository}, 't/local/MYCPAN', 'value for repository matches';
is $mcpi->config->{dirmode}, '0775', 'value for dirmode matches';
is $mcpi->config->{passive}, 'yes', 'value for passive matches';
};
done_testing();
|