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 => 14; |
plan tests => 37; |
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"); |
51 |
|
|
52 |
my $sql_filenames = qq{ |
my $sql_filenames = qq{ |
53 |
select |
select |
54 |
name as id, |
name as id, |
78 |
update => $sql_update, |
update => $sql_update, |
79 |
dsn => $dsn, |
dsn => $dsn, |
80 |
mount => $mount, |
mount => $mount, |
81 |
|
fork => 1, |
82 |
}); |
}); |
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 |
|
|
116 |
ok(unlink $test_db,"rm $test_db"); |
ok(unlink $test_db,"rm $test_db"); |
117 |
|
|
118 |
|
ok(!-e $test_db,"cleanup"); |