App-FileCleanerByDiskUage

 view release on metacpan or  search on metacpan

t/clean.t  view on Meta::CPAN

	is( $r->{unlinked_count},    3, 'dry_run: reports all three as would-be removed' );
	is( count_existing(@$files), 3, 'dry_run: nothing actually removed from disk' );
}

# a non-writable file in a dry run is reported as a failure, not a removal.
# skipped when running as root, where -w is effectively always true.
SKIP: {
	skip( 'writability check is unreliable when running as root', 2 ) if $> == 0;

	my ( $dir, $files ) = make_files(qw(a));
	chmod( 0400, $files->[0] );
	skip( 'could not make file non-writable', 2 ) if -w $files->[0];

	my $r = App::FileCleanerByDiskUage->clean( path => $dir, du => 0, dry_run => 1 );

	is( $r->{unlink_failed_count}, 1, 'dry_run: non-writable file recorded as failure' );
	is( count_existing(@$files),   1, 'dry_run: non-writable file left on disk' );

	chmod( 0600, $files->[0] );    # so File::Temp can clean up
}

# -------------------------------------------------------------------------
# input validation dies
# -------------------------------------------------------------------------
eval { App::FileCleanerByDiskUage->clean( du => 0 ); };
ok( $@, 'dies when path is undef' );

eval { App::FileCleanerByDiskUage->clean( path => tempdir( CLEANUP => 1 ) ); };
ok( $@, 'dies when du is undef' );



( run in 0.991 second using v1.01-cache-2.11-cpan-995e09ba956 )