ディレクトリが書き込み可能か読み取り可能かをチェックするモジュールを作成しました。しかし、どうやってテストするのですか?
通常、モジュールを作成するときは、モジュールの機能をテストするためのテストをいくつか作成できます。実際にモジュールを作成したテストで書き込みできないディレクトリを作成するにはどうすればよいですか?
私は次のようなものを想像します:
use strict;
use warnings;
use File::Temp qw/ tempdir /;
use Test::More tests => 5;
BEGIN { use_ok('My::DirCheck') };
my $readable_dir = tempdir();
my $check = My::DirCheck->new(directory => $readable_dir);
is($check->is_readable(), 1, 'temp dir is readable');
# FIXME: how to make it not readale?
isnt($check->is_readable(), 1, 'temp dir is not readable');
my $writable_dir = tempdir();
is($check->is_writeable(), 1, 'temp dir is writeable');
# FIXME: how to make it not writable?
isnt($check->is_writeable(), 1, 'temp dir is not writeable');
しかし、どのようにディレクトリを作成し、たとえば読み取り専用にして、後で削除するのですか?