Mock::FileSystem - Simulate filesystem resources to help testing modules that depends on filesystem objects
Version 0.01_001
Quick summary of what the module does.
Perhaps a little code snippet.
use Some::Module; use Test::Mock::FileSystem 'Some::Module'; mock_file '/tmp/something' => ( path => "/tmp/something", content => "Some content", mode => oct("4"), # read-only ctime => time() - 3600, # one hour ago ); # Then a sub in Some::Module sub open_file { my $self = shift; open my $fh, '<', '/tmp/something'; # This will print Some content print <$fh>; close $fh; } ...
A list of functions that can be exported. You can delete this section if you don't export anything, such as for a purely object-oriented module.
mock_file $file => %options
This will create a $file in the virtual file system and the parents directories. Additionally you can control the meta information of the file using the %options parameter. Here is a list of the valid options
$file
%options
content => $content
The fills the virtual file with $content. By default file have no content
$content
access => $access
Use this option to control the access bits of the file. The available bits are u g k r w x. So for example if $access is the value oct("6") the file will be readable and writable.
$access
oct("6")
uid => $uid
The option uid sets the owner of the file with $uid. The default value is whatever POSIX::getuid() returns.
uid
$uid
POSIX::getuid()
gid => $gid
The option gid sets the owning group of the file with $gid. The default value is whatever POSIX::getgid() returns
gid
$gid
POSIX::getgid()
atime => $time
The option atime set the access time with $time. The default value is the value returned by time() at the moment of file creation
atime
$time
time()
ctime => $time
The option ctime set the create time with $time. The default value is the value returned by time() at the moment of file creation
ctime
mtime => $time
The option mtime set the modified time with $time. The default value is the value returned by time() at the moment of file creation
mtime
Mariano Waghlmann, <dichoso _at_ gmail.com>
<dichoso _at_ gmail.com>
Please report any bugs or feature requests to bug-mock-filesystem at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mock-FileSystem. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-mock-filesystem at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Test::Mock::FileSystem
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Mock-FileSystem
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Test-Mock-FileSystem
CPAN Ratings
http://cpanratings.perl.org/d/Test-Mock-FileSystem
Search CPAN
http://search.cpan.org/dist/Test-Mock-FileSystem/
Copyright 2011 Mariano Wahlmann.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Test::Mock::FileSystem, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Mock::FileSystem
CPAN shell
perl -MCPAN -e shell install Test::Mock::FileSystem
For more information on module installation, please visit the detailed CPAN module installation guide.