Dist-Zilla-PluginBundle-Author-Plicease

 view release on metacpan or  search on metacpan

t/dist_zilla_plugin_author_plicease_upload.t  view on Meta::CPAN


my @keep;

sub tzil
{
  my(%config) = @_;

  my $pause = tempdir( CLEANUP => 1 );
  push @keep, $pause;
  $pause->child('.pause')->spew_utf8(
    $config{no_credentials} ? "" : "user FOOBAR\npassword secret\n"
  );
  delete $config{no_credentials};

  my $tzil = Builder->from_config(
    { dist_root => 'corpus/DZT' },
    {
      add_files => {
        'source/dist.ini' => simple_ini(
          {},
          # [GatherDir]
          'GatherDir',
          [ 'Author::Plicease::Upload' => {

t/dist_zilla_plugin_author_plicease_upload.t  view on Meta::CPAN

  $tzil->release;

  is
    \@uploaded,
    [ hash {
      field file     => match qr/DZT-Sample-0\.001\.tar\.gz$/;
      field user     => 'FOOBAR';
      field password => 'secret';
      end;
    } ],
    'uploaded to CPAN with credentials';

  note $_ for log_messages($tzil)->@*;

};

subtest 'upload to cpan without credentials' => sub {

  @uploaded = ();

  my $tzil = tzil( no_credentials => 1 );
  $tzil->chrome->set_response_for('upload to CPAN?' => 'y');
  $tzil->chrome->set_response_for('PAUSE username: ' => '');

  # before_release is a no-op, so missing credentials are not
  # fatal, they are just logged during release.
  ok lives { $tzil->release }, 'release does not die' or note $@;

  is \@uploaded, [], 'nothing uploaded';

  my $log = log_messages($tzil);
  note $_ for @$log;
  ok( (grep /error uploading to cpan: no username/, @$log), 'logged missing username' );
  ok( (grep /you will have to manually upload the dist/, @$log), 'logged manual upload' );



( run in 1.166 second using v1.01-cache-2.11-cpan-3f962061493 )