Archive-Libarchive-Extract

 view release on metacpan or  search on metacpan

t/archive_libarchive_extract.t  view on Meta::CPAN

use Test2::V0 -no_srand => 1;
use Archive::Libarchive::Extract;
use Path::Tiny qw( path );
use File::Temp qw( tempdir );
use Ref::Util qw( is_plain_coderef );
use File::chdir;
use experimental qw( signatures );

is(
  dies { Archive::Libarchive::Extract->new },
  match qr/^Required option: one of filename or memory at t\/archive_libarchiv/,
  'undef filename',
);

is(
  dies { Archive::Libarchive::Extract->new( filename => 'xxx', memory => 'yyy' ) },
  match qr/^Exactly one of filename or memory is required at t\/archive_libarchiv/,
  'undef filename',
);

is(
  dies { Archive::Libarchive::Extract->new( memory => 'yyy' ) },
  match qr/^Option memory must be a scalar reference to a plain non-reference scalar at t\/archive_libarchiv/,
  'undef filename',
);

is(
  dies { Archive::Libarchive::Extract->new( filename => 'bogus.tar' ) },
  match qr/^Missing or unreadable: bogus.tar at t\/archive_li/,
  'bad filename',
);

is(
  dies { Archive::Libarchive::Extract->new( filename => 'corpus/archive.tar', foo => 1, bar => 2 ) },
  match qr/^Illegal options: bar foo/,
  'bad filename',
);

subtest 'extract' => sub {

  foreach my $to (undef, tempdir( CLEANUP => 1 ))
  {

    foreach my $from ('memory','disk') {

      subtest "from <= $from, to => @{[ $to // 'undef' ]}" => sub {

        my $tarball;

        local $CWD = $CWD;

        if(defined $to)
        {
          $tarball = path('corpus/archive.tar');
          note "extracting to non-cwd $to";
          note "archive: $tarball";
        }
        else
        {
          $tarball = path('corpus/archive.tar')->absolute;
          $CWD = tempdir( CLEANUP => 1 );
          note "extracting to cwd $CWD";
          note "archive: $tarball";
        }

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.553 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )