CGI-Application-Plugin-Config-Simple

 view release on metacpan or  search on metacpan

t/main.t  view on Meta::CPAN

    # now let's test the config() method to see if we get a Config::Simple object
    $value = $self->config();
    is(ref($value), 'Config::Simple', 'config() returned object');
}

# 17..20
# lets cause some errors
SKIP: {
    # try to change it's permissions
    my $new_file = 't/test_unwriteable.ini';
    chmod(0000, $new_file) || die "Could not chmod $new_file! $!";
    # skip these tests if we can still read the file
    # cause we're probably running as root
    skip('user wont have permission issues', 4) if( -r $new_file );

    # un readable file
    $self->config_file($new_file);
    eval { $self->config_param('param1') };
    like($@, qr/Permission denied/i, 'un readable file');

    # un writeable file
    chmod(0400, $new_file)
        || die "Could not chmod $new_file! $!";
    my $value = $self->config_file($new_file);
    is($value, $new_file, 'new unwriteable file');
    eval { $self->config_param(param1 => 'xyz') };
    like($@, qr/Could not write/i, 'could not write');

    # don't specify a config file
    $ENV{CGIAPP_CONFIG_FILE} = '';
    $self->config_file('');
    eval { $self->config_param('param1') };
    like($@, qr/No config file/i, 'no file given');



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