Skip to content

Consider providing read and write helper for mocked files #111

Open
@atoomic

Description

@atoomic

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions