App-MechaCPAN

 view release on metacpan or  search on metacpan

t/22_install__get_targz.t  view on Meta::CPAN

use strict;
use FindBin;
use Test::More;
use File::Temp qw/tempdir/;

require q[./t/helper.pm];

if ( !&App::MechaCPAN::can_https )
{
  plan skip_all => 'Cannot test getting tar.gz when https is unavailable';
}

my $has_git = &App::MechaCPAN::has_git;
local $ENV{GIT_SSL_NO_VERIFY}='true';

# Don't bother with CHECKSUMS verification
local $App::MechaCPAN::CHKSIGS = 0;

# Notes:
#  * we don't test with git or ssh since those require some kind of login
#  * File::Remove is included to make sure that it's not confused with file://
foreach my $src (
  qw[
  test_dists/NoDeps/NoDeps-1.0.tar.gz
  authors/id/E/ET/ETHER/Try-Tiny-0.24.tar.gz
  E/ET/ETHER/Try-Tiny-0.24.tar.gz
  ETHER/Try-Tiny-0.24.tar.gz
  https://github.com/p5sagit/Try-Tiny.git
  https://github.com/p5sagit/Try-Tiny.git@v0.24
  https://github.com/p5sagit/Try-Tiny/archive/v0.24.zip
  Try::Tiny
  Try::Tiny@0.24
  Try::Tiny~0.24
  Try::Tiny~<0.24
  File::Remove
  ],
  [qw/Try::Tiny 0.24/],
  [qw/Try::Tiny <0.24/],
  )
{
SKIP:
  {
    if ( $src =~ m/[.]git/xms && !$has_git )
    {
      skip "git not available", 1;
    }

    local $App::MechaCPAN::Install::dest_dir
      = tempdir( TEMPLATE => File::Spec->tmpdir . '/mechacpan_XXXXXXXX',
      CLEANUP => 1 );

    my $target = App::MechaCPAN::Install::_create_target( $src, {} );
    local $@;
    my $tgz = eval { App::MechaCPAN::Install::_get_targz($target) };
    diag("Error: '$@'")
      if $@;

    if ( ref $tgz eq 'HASH' )
    {
      $tgz = $tgz->{src};
    }

    isnt( -s "$tgz", undef, "Got '$src'" );
  }
}

done_testing;



( run in 4.265 seconds using v1.01-cache-2.11-cpan-354807fb38d )