perl - How to write a test for testing if a folder is readable / writable -


i wrote module checks directory if writable or readable. but, how test it?

usually, when writing module can write tests testing features of module. how can create directory, not writable test created module?

i imagine this:

use strict; use warnings; use file::temp qw/ tempdir /;  use test::more tests => 5; begin { use_ok('my::dircheck') };  $readable_dir = tempdir(); $check = my::dircheck->new(directory => $readable_dir);  is($check->is_readable(), 1, 'temp dir readable');  # fixme: how make not readale? isnt($check->is_readable(), 1, 'temp dir not readable');   $writable_dir = tempdir();  is($check->is_writeable(), 1, 'temp dir writeable');  # fixme: how make not writable? isnt($check->is_writeable(), 1, 'temp dir not writeable'); 

but how create directory, make e.g read-only , rid of afterwards?

instead of file::temp, try use file::path, allows choose mode parameter able set directories's permissions. set mode 0000 directory without read, write nor execution permissions.

assuming perl core, should portable on of os.


Comments

Popular posts from this blog

ruby on rails - Is it the correct way to implement belongs_to relation with factory girl? -

geolocation - Windows Phone 8 - Keeping background location tracking active beyond four hours -

Uncaught TypeError: Cannot read property 'parentNode' of null javascript -