Alien-Build
view release on metacpan or search on metacpan
t/alien_build.t view on Meta::CPAN
},
'expected result';
};
subtest 'decode' => sub {
my $build = alienfile_ok q{
use alienfile;
probe sub { 'share' };
share {
decode sub {
my($build, $res) = @_;
if($res->{type} eq 'html')
{
die "did not get expected content" unless $res->{content} =~ /FAUX HTML/;
}
elsif($res->{type} eq 'dir_listing')
{
die "did not get expected content" unless $res->{content} =~ /FAUX DIR LISTING/;
}
else
{
die "test does not handle @{[ $res->{type} ]}";
}
return {
type => 'list',
list => [
{ filename => 'foo1.txt', url => "@{[ $res->{base} ]}/foo1.txt" },
{ filename => 'foo2.txt', url => "@{[ $res->{base} ]}/foo2.txt" },
],
};
};
};
};
alienfile_skip_if_missing_prereqs;
alien_install_type_is 'share';
is
$build->decode({
type => 'html',
base => 'http://foo.com',
content => 'my FAUX HTML content',
protocol => 'http',
}),
hash {
field type => 'list';
field protocol => 'http';
field list => [
{ filename => 'foo1.txt', url => 'http://foo.com/foo1.txt' },
{ filename => 'foo2.txt', url => 'http://foo.com/foo2.txt' },
];
end;
},
'decoded html';
is
$build->decode({
type => 'dir_listing',
base => 'ftp://foo.com',
content => 'my FAUX DIR LISTING content',
protocol => 'ftp',
}),
hash {
field type => 'list';
field protocol => 'ftp';
field list => [
{ filename => 'foo1.txt', url => 'ftp://foo.com/foo1.txt' },
{ filename => 'foo2.txt', url => 'ftp://foo.com/foo2.txt' },
];
end;
},
'decoded dir listing';
};
subtest 'alien_download_rule' => sub {
local $ENV{ALIEN_DOWNLOAD_RULE};
delete $ENV{ALIEN_DOWNLOAD_RULE};
is(
Alien::Build->new,
object {
call download_rule => 'warn';
},
'implicit default');
is(
do { $ENV{ALIEN_DOWNLOAD_RULE} = 'default'; Alien::Build->new },
object {
call download_rule => 'warn';
},
'explicit default');
foreach my $value ( qw( warn digest encrypt digest_or_encrypt digest_and_encrypt ) )
{
local $ENV{ALIEN_DOWNLOAD_RULE} = $value;
is(
Alien::Build->new,
object {
call download_rule => $value;
# changing the enviroment after the first call should not do anything
call sub {
$ENV{ALIEN_DOWNLOAD_RULE} = $value eq 'warn' ? 'digest' : 'warn';
shift->download_rule;
} => $value;
},
"override $value");
}
$ENV{ALIEN_DOWNLOAD_RULE} = 'bogus';
my @w;
my $mock = mock 'Alien::Build' => (
override => [
log => sub {
my(undef, $msg) = @_;
push @w, $msg if $msg =~ /^unknown ALIEN_DOWNLOAD_RULE/;
},
]
);
is(
Alien::Build->new,
object {
call download_rule => 'warn';
},
( run in 0.891 second using v1.01-cache-2.11-cpan-411bb0df24b )