4 |
use warnings; |
use warnings; |
5 |
|
|
6 |
use Test::More; |
use Test::More; |
7 |
|
use File::Find; |
8 |
use blib; |
use blib; |
9 |
|
|
10 |
eval "use DBD::SQLite"; |
eval "use DBD::SQLite"; |
11 |
plan skip_all => "DBD::SQLite required for testing" if $@; |
plan skip_all => "DBD::SQLite required for testing" if $@; |
12 |
plan tests => 15; |
plan tests => 36; |
13 |
|
|
14 |
use_ok('DBI'); |
use_ok('DBI'); |
15 |
use_ok('Fuse::DBI'); |
use_ok('Fuse::DBI'); |
39 |
insert into files (name,data) values (?,?) |
insert into files (name,data) values (?,?) |
40 |
}), "prepare"); |
}), "prepare"); |
41 |
|
|
42 |
foreach my $file (qw(file dir/file dir/subdir/file)) { |
my @files = qw(file dir/file dir/subdir/file); |
43 |
my $data = "this is test data\n" x length($file); |
my %file_data; |
44 |
ok($sth->execute($file,$data), "insert $file"); |
|
45 |
|
foreach my $file (@files) { |
46 |
|
$file_data{$file} = ("this is test data on ".localtime()."\n") x length($file); |
47 |
|
ok($sth->execute($file,$file_data{$file}), "insert $file"); |
48 |
} |
} |
49 |
|
|
50 |
ok($dbh->disconnect, "disconnect after insert"); |
ok($dbh->disconnect, "disconnect after insert"); |
83 |
|
|
84 |
ok($mnt, "mount"); |
ok($mnt, "mount"); |
85 |
|
|
86 |
diag "press enter to continue"; |
sub test_file { |
87 |
my $foo = <STDIN>; |
my $f = $File::Find::name; |
88 |
|
|
89 |
|
ok($f, "file $f"); |
90 |
|
|
91 |
|
return unless (-f $f); |
92 |
|
|
93 |
|
ok(open(F, $f), "open"); |
94 |
|
my $tmp = ''; |
95 |
|
while(<F>) { |
96 |
|
$tmp .= $_; |
97 |
|
} |
98 |
|
ok(close(F), "close"); |
99 |
|
|
100 |
|
# strip mountpoint |
101 |
|
$f =~ s#^\Q$mount\E/##; |
102 |
|
|
103 |
|
ok($file_data{$f}, "$f exists"); |
104 |
|
|
105 |
|
cmp_ok(length($file_data{$f}), '==', length($tmp), "size"); |
106 |
|
cmp_ok($file_data{$f}, 'eq', $tmp, "content"); |
107 |
|
} |
108 |
|
|
109 |
|
# small delay so that filesystem could mount |
110 |
|
sleep(1); |
111 |
|
|
112 |
|
find({ wanted => \&test_file, no_chdir => 1 }, $mount); |
113 |
|
|
114 |
ok($mnt->umount,"umount"); |
ok($mnt->umount,"umount"); |
115 |
|
|