Network shares mounted locally should behave the same as local filesystems for basic operations (open, read, write). If you're only listing directories and testing filenames, it should work just fine to create the file structure locally and test against that. If you need to simulate large file sizes, you could abstract out the fetching of the file size into a sub get_size { my ($filename) = @_; ... }, and then mock that during testing (more advanced monks may know if it's possible to mock -s directly...?).

However, if you're going to be doing other things like file locking or reading file attributes other than size and modification time, support for that can vary wildly depending on protocol, software versions, etc. Also of course each software and protocol may have some other small quirks here and there.

As for switching locations to test against, if it's a single test program, then a command line arg should be enough; if it's a suite of test scripts, an environment variable is easiest.

To keep your test suite small, you could include a script that generates the fake directory structures for you (for example, create a temp dir via File::Temp, generate the files there, and test against that).

What OS will you be running on? Also, if you haven't seen them yet, the excellent Path::Class and File::Find::Rule modules should help you in navigating the directory structure.

(A bit of Googling brings up Filesys::Virtual::Async and Test::Virtual::Filesystem, maybe those can help too.)


In reply to Re: Mock/Fake network fileshare for my new modules Test Suite by Anonymous Monk
in thread Mock/Fake network fileshare for my new modules Test Suite by Galdor

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.