CPAN-Common-Index
view release on metacpan or search on metacpan
t/mux-ordered.t view on Meta::CPAN
use 5.008001;
use strict;
use warnings;
use Test::More 0.96;
use Test::FailWarnings;
use Test::Deep '!blessed';
use Test::Fatal;
use Cwd qw/getcwd/;
use File::Temp;
use lib 't/lib';
use CommonTests;
my $cwd = getcwd;
my $test_mirror = "file:///$cwd/t/CPAN";
my $local_pkg = "t/CUSTOM/uncompressed";
my $cache = File::Temp->newdir;
require_ok("CPAN::Common::Index::Mirror");
require_ok("CPAN::Common::Index::LocalPackage");
require_ok("CPAN::Common::Index::Mux::Ordered");
my $mirror_index =
CPAN::Common::Index::Mirror->new( { cache => $cache, mirror => $test_mirror } );
my $local_index = CPAN::Common::Index::LocalPackage->new(
{ cache => $cache, source => $local_pkg } );
subtest "constructor tests" => sub {
# no arguments, all defaults
new_ok(
'CPAN::Common::Index::Mux::Ordered' => [],
"new with no args"
);
# single resolver specified
new_ok(
'CPAN::Common::Index::Mux::Ordered' => [ { resolvers => [$mirror_index] } ],
"new with single mirror resolver"
);
# bad resolver argument
eval { CPAN::Common::Index::Mux::Ordered->new( { resolvers => "Foo" } ) };
like(
$@ => qr/The 'resolvers' argument must be an array reference/,
"Bad resolver dies with error"
);
};
subtest "find package" => sub {
my $index = new_ok(
'CPAN::Common::Index::Mux::Ordered' =>
[ { resolvers => [ $local_index, $mirror_index ] } ],
"new with single mirror resolver"
);
test_find_package($index);
# test finding darkpan from local
{
my $expected = {
'package' => 'ZZZ::Custom',
'uri' => 'cpan:///distfile/LOCAL/ZZZ-Custom-1.2.tar.gz',
'version' => '1.2'
};
my $got = $index->search_packages( { package => 'ZZZ::Custom' } );
is_deeply( $got, $expected, "Found custom package" );
( run in 0.768 second using v1.01-cache-2.11-cpan-54e63673c56 )