Dist-Zilla-Plugin-MetaProvides
view release on metacpan or search on metacpan
t/01-Provider/03-metanoindex.t view on Meta::CPAN
use strict;
use warnings;
use Test::More 0.96;
use Test::Fatal;
use Path::Tiny qw( path );
use Test::DZil qw( simple_ini Builder );
use lib 't/lib';
# Keepalive
my $builder;
sub make_plugin_metanoindex {
my $iconfig = shift;
$builder = Builder->from_config(
{ dist_root => 'invalid' },
{
add_files => {
path('source/dist.ini') => simple_ini(
[ 'FakePlugin' => $iconfig->{fakeplugin} ], #
[ 'MetaNoIndex' => $iconfig->{noindex} ], #
)
},
},
);
return $builder->plugin_named('FakePlugin');
}
subtest '_try_regen_metadata tests' => sub {
if ( not defined eval 'use Dist::Zilla::Plugin::MetaNoIndex;1' ) {
plan skip_all => 'MetaNoIndex subtests invaid without the plugin';
#return;
}
subtest 'empty noindex params' => sub {
my $plugin = make_plugin_metanoindex( { fakeplugin => {}, noindex => {} } );
my $metadata = {};
is( exception { $metadata = $plugin->_try_regen_metadata() }, undef, 'regenerting metadata manually does not fail' );
is_deeply( $metadata, { no_index => {} }, 'Metadata is empty' );
};
subtest 'noindex params arrive' => sub {
my $plugin = make_plugin_metanoindex( { fakeplugin => {}, noindex => { file => ['foo.pl'] } } );
my $metadata = {};
is( exception { $metadata = $plugin->_try_regen_metadata() }, undef, 'regenerting metadata manually does not fail' );
is_deeply( $metadata, { no_index => { file => ['foo.pl'] } }, 'NoIndex params arrive' );
};
};
subtest '_apply_meta_noindex tests' => sub {
if ( not defined eval 'use Dist::Zilla::Plugin::MetaNoIndex;1' ) {
plan skip_all => 'MetaNoIndex subtests invaid without the plugin';
#return;
}
my $rules = {
file => ['foo.pl'],
dir => [ 'ignoreme', 'ignoreme/too' ],
package => ['Test::YouShouldNot::SeeThis'],
namespace => ['Test::ThisIsAlso'],
};
my ( $normal_plugin, $noindex_plugin );
is(
exception {
$normal_plugin = make_plugin_metanoindex( { fakeplugin => { meta_noindex => 0 }, noindex => $rules } );
$noindex_plugin = make_plugin_metanoindex( { fakeplugin => { meta_noindex => 1 }, noindex => $rules } );
},
( run in 1.972 second using v1.01-cache-2.11-cpan-e1769b4cff6 )