Dist-Zilla-PluginBundle-Codeberg

 view release on metacpan or  search on metacpan

t/tests/dist/zilla/app/command/codeberg.t  view on Meta::CPAN

use Modern::Perl;
use Test2::V1 -ipP;
use Test2::Tools::Compare qw/hash array bag item match end/;
use Test2::Tools::Explain;
use Test2::Tools::JSON;
use FindBin;
use lib "$FindBin::Bin/../lib";
use Path::Tiny;
use Storable   qw(dclone);
use Test::DZil qw(simple_ini);
use Dist::Zilla::App::Tester;

use Dist::Zilla::App::Command::codeberg;
use Dist::Zilla::Plugin::Codeberg;
my $mock_dist_zilla_plugin_codeberg
   = mock 'Dist::Zilla::Plugin::Codeberg' => (
   override => [
      _build_credentials =>
         sub { return { login => 'bob', token => 'AbC00ToKeN' } },
      _get_repo_name => sub { return 'bob/DZT-Sample' },
   ],
   );

my @http_requests;

use HTTP::Tiny;
my $mock_http_tiny = mock 'HTTP::Tiny' => (
   override => [
      request => sub {
         my $self = shift;
         push @http_requests, dclone( [@_] );
         return { success => 1, content => '{}' };
      }
   ]
);

# a stand-in for the minter built from a real profile, so 'create' can be
# tested without needing an actual Codeberg::Create-enabled minting profile
# installed on the system
{

   package Test::Codeberg::FakeCreatePlugin;

   sub new {
      my $class = shift;
      return bless { after_mint_calls => [], @_ }, $class;
   }
   sub plugin_name { return 'Codeberg::Create' }

   sub after_mint {
      my ( $self, $opts ) = @_;
      push @{ $self->{after_mint_calls} }, $opts;
      return;
   }
}
{

   package Test::Codeberg::FakeMinter;
   sub new     { my $class = shift; return bless {@_}, $class }
   sub plugins { return $_[0]->{plugins} }
}

sub write_source_dist {
   my $dir = Path::Tiny->tempdir;
   $dir->child('dist.ini')->spew_utf8(
      simple_ini(
         [ GatherDir          => ],
         [ 'Codeberg::Update' => {} ],
      )
   );
   $dir->child('lib')->mkpath;
   $dir->child( 'lib', 'Foo.pm' )->spew_utf8("package Foo;\n1;\n");
   return $dir;
}

subtest 'command metadata' => sub {
   plan( tests => 3 );



( run in 1.076 second using v1.01-cache-2.11-cpan-007c89162af )