diff --git a/Makefile.PL b/Makefile.PL index 8982f83..ea1d60e 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -74,6 +74,7 @@ my %WriteMakefile = ( 'Test::More' => '1', 'Test::Output' => '0', 'Test::Without::Module' => '0', + 'Capture::Tiny' => '0', }, 'META_MERGE' => { diff --git a/t/passwords.t b/t/passwords.t new file mode 100644 index 0000000..b557b7f --- /dev/null +++ b/t/passwords.t @@ -0,0 +1,55 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use Test::More tests => 7; +use Capture::Tiny qw(capture_stderr); + +use Module::Release; + +BEGIN { + use File::Spec; + my $file = File::Spec->catfile(qw(. t lib setup_common.pl)); + require $file; +} + +my $release = Module::Release->new; + +$release->turn_debug_on; + +{ + my $output = capture_stderr { $release->check_for_passwords }; + is( + $output, + "CPAN pass is \n", + "Debug output shows empty password when password unset" + ); +} + +{ + $ENV{'CPAN_PASS'} = 's3cr3t'; + my $output = capture_stderr { $release->check_for_passwords }; + is( $release->config->cpan_pass, + undef, "Password is unset when cpan username is not set" ); + is( + $output, + "CPAN pass is \n", + 'Debug output shows unset password when cpan username is not set' + ); +} + +{ + $ENV{'CPAN_PASS'} = 's3cr3t'; + $release->config->set( 'cpan_user', 'BDFOY' ); + my $output = capture_stderr { $release->check_for_passwords }; + is( $release->config->cpan_pass, + 's3cr3t', "Password is set when CPAN_PASS is set" ); + is( + $output, + "CPAN pass is s3cr3t\n", + 'Debug output shows password when set' + ); +} + +# vim: expandtab shiftwidth=4