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