Alien-Build

 view release on metacpan or  search on metacpan

t/alien_build_plugin_extract_negotiate.t  view on Meta::CPAN

    my $have_archive_zip = 0;
    my $have_info_zip    = 0;

    my $mock1 = mock 'Alien::Build::Plugin::Extract::ArchiveZip' => (
      override => [
        available => sub {
          my(undef, $format) = @_;
          !!($format eq 'zip' && $have_archive_zip);
        },
      ],
    );


    my $mock2 = mock 'Alien::Build::Plugin::Extract::CommandLine' => (
      override => [
        available => sub {
          my(undef, $format) = @_;
          !!($format eq 'zip' && $have_info_zip);
        },
      ],
    );

    subtest 'nada' => sub {

      is(
        Alien::Build::Plugin::Extract::Negotiate->pick('zip'),
        'Extract::CommandLine',
      );

    };

    subtest 'just Archive::Zip' => sub {

      $have_archive_zip = 1;
      $have_info_zip    = 0;

      is(
        Alien::Build::Plugin::Extract::Negotiate->pick('zip'),
        'Extract::ArchiveZip',
      );

    };

    subtest 'just info zip' => sub {

      $have_archive_zip = 0;
      $have_info_zip    = 1;

      is(
        Alien::Build::Plugin::Extract::Negotiate->pick('zip'),
        'Extract::CommandLine',
      );

    };

    subtest 'both' => sub {

      $have_archive_zip = 1;
      $have_info_zip    = 1;

      # Not 100% sure this is the best choice now that I think of it.
      is(
        Alien::Build::Plugin::Extract::Negotiate->pick('zip'),
        'Extract::ArchiveZip',
      );

    };


  };

};

done_testing;



( run in 0.791 second using v1.01-cache-2.11-cpan-9581c071862 )