Revision c0b53018
Von Moritz Bunkus vor fast 8 Jahren hinzugefügt
t/file/filesystem.t | ||
---|---|---|
2 | 2 |
use Test::More tests => 11; |
3 | 3 |
|
4 | 4 |
use lib 't'; |
5 |
|
|
6 |
use File::Temp; |
|
5 | 7 |
use Support::TestSetup; |
6 | 8 |
use Test::Exception; |
7 | 9 |
use SL::File; |
... | ... | |
9 | 11 |
|
10 | 12 |
Support::TestSetup::login(); |
11 | 13 |
|
14 |
my $temp_dir = File::Temp::tempdir("kivi-t-file-filesystem.XXXXXX", TMPDIR => 1, CLEANUP => 1); |
|
15 |
my $storage_dir = "$temp_dir/storage"; |
|
16 |
|
|
17 |
mkdir($storage_dir) || die $!; |
|
18 |
|
|
12 | 19 |
my $db = SL::DB::Object->new->db; |
13 | 20 |
$db->dbh->do("UPDATE defaults SET doc_files = 't'"); |
14 |
$db->dbh->do("UPDATE defaults SET doc_files_rootpath = '/var/tmp/kivifs'");
|
|
21 |
$db->dbh->do("UPDATE defaults SET doc_files_rootpath = ?", undef, $storage_dir);
|
|
15 | 22 |
|
16 |
my $scannerfile = '/var/tmp/f2';
|
|
23 |
my $scannerfile = "${temp_dir}/f2";
|
|
17 | 24 |
|
18 | 25 |
clear_up(); |
19 | 26 |
reset_state(); |
... | ... | |
77 | 84 |
done_testing; |
78 | 85 |
|
79 | 86 |
sub clear_up { |
80 |
SL::Dev::File->delete_all(); |
|
81 |
unlink($scannerfile); |
|
82 |
}; |
|
87 |
# Cleaning up may fail. |
|
88 |
eval { |
|
89 |
SL::Dev::File->delete_all(); |
|
90 |
unlink($scannerfile); |
|
91 |
}; |
|
92 |
} |
|
83 | 93 |
|
84 | 94 |
sub reset_state { |
85 | 95 |
my %params = @_; |
Auch abrufbar als: Unified diff
t/file/filesystem.t: keinen festen Namen für temporäres Verzeichnis nutzen
Weiterhin muss das Verzeichnis angelegt werden. Der Test darf sich nicht
darauf verlassen, dass er einfach durchläuft.