X-Git-Url: http://git.rot13.org/?p=Fuse-DBI;a=blobdiff_plain;f=t%2F02sqlite.t;h=4f0d593c16f2c5900bb9b2c9f0a4720a5455cd48;hp=28a58c44c7bf617f0d2cd0c1d046451f5ba3fbab;hb=8b53b090ace163fc02e100998eda16f4a0c0435b;hpb=dfe093fd14289091f1adf7afc9221e5a50c483dd diff --git a/t/02sqlite.t b/t/02sqlite.t index 28a58c4..4f0d593 100755 --- a/t/02sqlite.t +++ b/t/02sqlite.t @@ -4,11 +4,12 @@ use strict; use warnings; use Test::More; +use File::Find; use blib; eval "use DBD::SQLite"; plan skip_all => "DBD::SQLite required for testing" if $@; -plan tests => 15; +plan tests => 36; use_ok('DBI'); use_ok('Fuse::DBI'); @@ -38,9 +39,12 @@ ok(my $sth = $dbh->prepare(qq{ insert into files (name,data) values (?,?) }), "prepare"); -foreach my $file (qw(file dir/file dir/subdir/file)) { - my $data = "this is test data\n" x length($file); - ok($sth->execute($file,$data), "insert $file"); +my @files = qw(file dir/file dir/subdir/file); +my %file_data; + +foreach my $file (@files) { + $file_data{$file} = ("this is test data on ".localtime()."\n") x length($file); + ok($sth->execute($file,$file_data{$file}), "insert $file"); } ok($dbh->disconnect, "disconnect after insert"); @@ -79,8 +83,33 @@ my $mnt = Fuse::DBI->mount({ ok($mnt, "mount"); -diag "press enter to continue"; -my $foo = ; +sub test_file { + my $f = $File::Find::name; + + ok($f, "file $f"); + + return unless (-f $f); + + ok(open(F, $f), "open"); + my $tmp = ''; + while() { + $tmp .= $_; + } + ok(close(F), "close"); + + # strip mountpoint + $f =~ s#^\Q$mount\E/##; + + ok($file_data{$f}, "$f exists"); + + cmp_ok(length($file_data{$f}), '==', length($tmp), "size"); + cmp_ok($file_data{$f}, 'eq', $tmp, "content"); +} + +# small delay so that filesystem could mount +sleep(1); + +find({ wanted => \&test_file, no_chdir => 1 }, $mount); ok($mnt->umount,"umount");