The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mock::FileSystem - Simulate filesystem resources to help testing modules that depends on filesystem objects

VERSION

Version 0.01_001

SYNOPSIS

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;
    }
    
    ...

EXPORTED FUNCTIONS

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_dir $file => %options

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

content => $content

The fills the virtual file with $content. By default file have no 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.

uid => $uid

The option uid sets the owner of the file with $uid. The default value is whatever POSIX::getuid() returns.

gid => $gid

The option gid sets the owning group of the file with $gid. The default value is whatever POSIX::getgid() returns

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

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

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

SUBROUTINES/METHODS

function1

function2

AUTHOR

Mariano Waghlmann, <dichoso _at_ gmail.com>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Test::Mock::FileSystem

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

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.