Skip to content

Commit

Permalink
Fix tests that failed if run as root
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony J. Mirabella committed Apr 30, 2011
1 parent f473e34 commit 733a924
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/Hostfile/Manager.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use File::Find;
use File::Slurp;
use File::Basename qw/dirname/;

our $VERSION = '0.06';
our $VERSION = '0.07';

=head1 NAME
Expand Down
23 changes: 13 additions & 10 deletions t/tests/Test/Hostfile/Manager.pm
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,19 @@ sub write_hostfile_requires_writable : Tests(3) {

can_ok $manager, 'write_hostfile';

my $file2 = 't/fixtures/hosts/write_test';
write_file( $file2, '' );
chmod 0444, $file2;

$manager->hostfile_path($file2);
throws_ok { $manager->write_hostfile } qr/^Unable to write hostfile/,
'... and write_hostfile chokes when trying to write to file without permissions';
is '', read_file($file2), "... and hostfile written to $file2";

unlink($file2);
SKIP: {
skip 'Cannot test writable requirements as root', 2 if ($< == 0);
my $file2 = 't/fixtures/hosts/write_test';
write_file( $file2, '' );
chmod 0444, $file2;

$manager->hostfile_path($file2);
throws_ok { $manager->write_hostfile } qr/^Unable to write hostfile/,
'... and write_hostfile chokes when trying to write to file without permissions';
is '', read_file($file2), "... and hostfile NOT written to $file2";

unlink($file2);
}
}

sub fragment_enabled : Tests(3) {
Expand Down

0 comments on commit 733a924

Please sign in to comment.