Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider providing read and write helper for mocked files #111

Open
atoomic opened this issue Jan 27, 2022 · 2 comments
Open

Consider providing read and write helper for mocked files #111

atoomic opened this issue Jan 27, 2022 · 2 comments
Labels
Feature Request New feature or request

Comments

@atoomic
Copy link
Contributor

atoomic commented Jan 27, 2022

Currently we can use the ->contents helper to update the content of a mocked file.
This is a convenient helper as of course we could also use any traditional way to write to the file.

This case is about providing two convenient helpers read and write which would only make sense in the context of a file (should die when used on a mocked directory and a symlink)

my $f = Test::MockFile->file( "/my/file" );

$f->write( "content" ) or die;

# maybe consider
$f->write( @lines ) or die;
$f->append( $new_line ) or die;
$f->append( @lines) or die;

my $content = $f->read;
my @lines = $f->read;
@atoomic atoomic added the Feature Request New feature or request label Jan 27, 2022
@atoomic
Copy link
Contributor Author

atoomic commented Jan 27, 2022

append would be a bonus

@xsawyerx
Copy link
Contributor

I think this should fall under a new interface: GH #115.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request New feature or request
Development

No branches or pull requests

2 participants