/[fuse_dbi]/trunk/t/03pgsql.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/03pgsql.t

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

revision 22 by dpavlin, Sat Oct 2 16:30:16 2004 UTC revision 59 by dpavlin, Mon Jun 20 21:15:05 2005 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::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 => 47;
13    
14  use_ok('DBI');  use_ok('DBI');
15  use_ok('Fuse::DBI');  use_ok('Fuse::DBI');
# Line 35  ok($dbh->do(qq{ Line 36  ok($dbh->do(qq{
36          )          )
37  }), "create table files");  }), "create table files");
38    
39  ok(my $sth = $dbh->prepare(qq{  ok(my $sth_insert = $dbh->prepare(qq{
40          insert into files (name,data) values (?,?)          insert into files (name,data) values (?,?)
41  }), "prepare");  }), "prepare insert");
42    
43  foreach my $file (qw(file dir/file dir/subdir/file)) {  ok(my $sth_select = $dbh->prepare(qq{
44          my $data = "this is test data\n" x length($file);          select data from files where name = ?
45          ok($sth->execute($file,$data), "insert $file");  }), "prepare select");
46    
47    my @files = qw(file dir/file dir/subdir/file);
48    my %file_data;
49    
50    foreach my $file (@files) {
51            $file_data{$file} = ("this is test data on ".localtime()."\n") x length($file);
52            ok($sth_insert->execute($file,$file_data{$file}), "insert $file");
53  }  }
54    
55  my $sql_filenames = qq{  my $sql_filenames = qq{
# Line 78  my $mnt = Fuse::DBI->mount({ Line 86  my $mnt = Fuse::DBI->mount({
86    
87  ok($mnt, "mount");  ok($mnt, "mount");
88    
89  diag "press enter to continue";  sub test_file {
90  my $foo = <STDIN>;          my $f = $File::Find::name;
91    
92            ok($f, "file $f");
93    
94            return unless (-f $f);
95    
96            ok(open(F, $f), "open read $f");
97            my $tmp = '';
98            while(<F>) {
99                    $tmp .= $_;
100            }
101            ok(close(F), "close");
102    
103            # strip mountpoint
104            $f =~ s#^\Q$mount\E/##;
105    
106            ok($file_data{$f}, "$f exists");
107    
108            cmp_ok(length($file_data{$f}), '==', length($tmp), "size");
109            cmp_ok($file_data{$f}, 'eq', $tmp, "content");
110    
111            $tmp =~ tr/a-z/A-Z/;
112            $tmp .= $f;
113    
114            ok(open(F, "> $mount/$f"), "open write $mount/$f");
115            print F $tmp;
116            ok(close(F), "close");
117    
118            ok($sth_select->execute($f), "select $f");
119            cmp_ok($sth_select->fetchrow_array(), 'eq', $tmp, "updated content");
120    }
121    
122    # small delay so that filesystem could mount
123    sleep(1);
124    
125    find({ wanted => \&test_file, no_chdir => 1 }, $mount);
126    
127  ok($mnt->umount,"umount");  ok($mnt->umount,"umount");
128    
129    undef $sth_select;
130    undef $sth_insert;
131    
132    ok($dbh->disconnect, "disconnect");

Legend:
Removed from v.22  
changed lines
  Added in v.59

  ViewVC Help
Powered by ViewVC 1.1.26