Alien-Build-Git

 view release on metacpan or  search on metacpan

t/alien_build_plugin_fetch_git.t  view on Meta::CPAN

use Test2::V0 -no_srand => 1;
use Test::Alien::Build;
use Alien::Build::Plugin::Fetch::Git;
use lib 't/lib';
use Repo;
use Capture::Tiny qw( capture_merged );
use Path::Tiny qw( path );
use Test2::Tools::URL 0.02;

my $build = alienfile_ok q{
  use alienfile;

  plugin 'Fetch::Git';
};

$build->load_requires('share');

my $example1 = example1();
note "example1 = $example1";

subtest 'fetch with tag' => sub {

  my $ret;
  my $error;
  my $out;

  note $out = capture_merged {
    $ret = eval { $build->fetch("$example1#0.02") };
    $error = $@;
  };

  is $error, '';
  diag $out if $error;

  is(
    $ret,
    hash {
      field filename => 'example1';
      field path     => match(qr/example1/);
      field type     => 'file';
      field protocol => 'file';
      end;
    },
  );

  is(
    path($ret->{path})->child('content.txt')->slurp,
    "This is version 0.02\n",
  );

};

subtest 'fetch without tag' => sub {

  my $ret;
  my $error;
  my $out;

  note $out = capture_merged {
    $ret = eval { $build->fetch("$example1") };
    $error = $@;
  };

  is $error, '';



( run in 0.850 second using v1.01-cache-2.11-cpan-119454b85a5 )