/[fuse_dbi]/trunk/t/02sqlite.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/t/02sqlite.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 32 by dpavlin, Sat Oct 2 16:30:16 2004 UTC revision 33 by dpavlin, Mon Nov 15 20:55:10 2004 UTC
# Line 4  use strict; Line 4  use strict;
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');
# Line 38  ok(my $sth = $dbh->prepare(qq{ Line 39  ok(my $sth = $dbh->prepare(qq{
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");
# Line 79  my $mnt = Fuse::DBI->mount({ Line 83  my $mnt = Fuse::DBI->mount({
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    

Legend:
Removed from v.32  
changed lines
  Added in v.33

  ViewVC Help
Powered by ViewVC 1.1.26