CPAN-Reporter

 view release on metacpan or  search on metacpan

t/03_config_file.t  view on Meta::CPAN

is_deeply( $new_config->{_}, $default_options,
    "newly created config file has expected defaults"
);


#--------------------------------------------------------------------------#
# check error handling if not readable
#--------------------------------------------------------------------------#

my $original_mode = (stat $config_file)[2] & 07777;
chmod 0, $config_file ;

SKIP:
{
    skip "Couldn't set config file unreadable; skipping related tests", 2
        if -r $config_file;

    {
        local $ENV{PERL_MM_USE_DEFAULT} = 1;  # use prompt defaults

        my $ret;
        ($stdout, $stderr) = capture { $ret = CPAN::Reporter::configure() };

        is( $ret, undef, "configure() is undef if file not readable" );
    }

    like( $stdout, "/couldn't read configuration file/",
        "opening non-readable file gives a warning"
    );
}

chmod $original_mode, $config_file;
ok( -r $config_file,
    "config file reset to readable"
);

#--------------------------------------------------------------------------#
# check error handling if not writeable 
#--------------------------------------------------------------------------#

chmod 0444, $config_file;

SKIP:
{
    skip "Couldn't set config file unwritable; skipping related tests", 2
        if -w $config_file;

    {
        local $ENV{PERL_MM_USE_DEFAULT} = 1;  # use prompt defaults

        my $ret;
        ($stdout, $stderr) = capture { $ret = CPAN::Reporter::configure() };

        is( $ret, undef, "configure() is undef if file not writeable" );
    }

    like( $stdout, "/error writing config file/",
        "opening non-writeable file gives a warning"
    );
}

chmod $original_mode, $config_file;
ok( -w $config_file,
    "config file reset to writeable"
);

#--------------------------------------------------------------------------#
# confirm configure() preserves existing
#--------------------------------------------------------------------------#

SKIP:
{

t/66_have_tested.t  view on Meta::CPAN

my @aoh;

mkpath( $config_dir );
ok( -d $config_dir, "temporary config dir created" );

# If old history exists, convert it
copy( $sample_history_file, $history_file);
ok( -f $history_file, "copied sample old history file to config directory");

# make it writeable
chmod 0644, $history_file;
ok( -w $history_file, "history file is writeable" );

# load CPAN::Reporter::History and import have_tested for convenience
require_ok( 'CPAN::Reporter::History' );
CPAN::Reporter::History->import( 'have_tested' );

# put in some data for current perl/arch/osname
CPAN::Reporter::History::_record_history($_) for @fake_results;

# one parameter should die



( run in 0.283 second using v1.01-cache-2.11-cpan-496ff517765 )