11 plan skip_all => "DBD::Pg required for testing" if $@;
18 my $dsn = "DBI:Pg:dbname=$test_db";
19 my $mount = '/tmp/fuse_dbi_mnt';
21 ok((! -e $mount || rmdir $mount), "mount point $mount");
23 mkdir $mount || die "mkdir $mount: $!";
24 ok(-d $mount, "mkdir $mount");
26 ok(my $dbh = DBI->connect($dsn, , '', '', { RaiseError => 1 }),
27 "connect fusedbi test database");
29 my $drop = eval { $dbh->do(qq{ drop table files }) };
30 diag "drop table files" if ($drop);
34 name text primary key,
37 }), "create table files");
39 ok(my $sth = $dbh->prepare(qq{
40 insert into files (name,data) values (?,?)
43 my @files = qw(file dir/file dir/subdir/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");
51 ok($dbh->disconnect, "disconnect after insert");
53 my $sql_filenames = qq{
74 system "fusermount -q -u $mount" || diag "nothing mounted at $mount, ok";
76 my $mnt = Fuse::DBI->mount({
77 filenames => $sql_filenames,
79 update => $sql_update,
88 my $f = $File::Find::name;
92 return unless (-f $f);
94 ok(open(F, $f), "open");
99 ok(close(F), "close");
102 $f =~ s#^\Q$mount\E/##;
104 ok($file_data{$f}, "$f exists");
106 cmp_ok(length($file_data{$f}), '==', length($tmp), "size");
107 cmp_ok($file_data{$f}, 'eq', $tmp, "content");
110 # small delay so that filesystem could mount
113 find({ wanted => \&test_file, no_chdir => 1 }, $mount);
115 ok($mnt->umount,"umount");