/[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 58 by dpavlin, Tue Nov 16 15:32:21 2004 UTC revision 59 by dpavlin, Mon Jun 20 21:15:05 2005 UTC
# Line 9  use blib; Line 9  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 => 34;  plan tests => 47;
13    
14  use_ok('DBI');  use_ok('DBI');
15  use_ok('Fuse::DBI');  use_ok('Fuse::DBI');
# Line 36  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    ok(my $sth_select = $dbh->prepare(qq{
44            select data from files where name = ?
45    }), "prepare select");
46    
47  my @files = qw(file dir/file dir/subdir/file);  my @files = qw(file dir/file dir/subdir/file);
48  my %file_data;  my %file_data;
49    
50  foreach my $file (@files) {  foreach my $file (@files) {
51          $file_data{$file} = ("this is test data on ".localtime()."\n") x length($file);          $file_data{$file} = ("this is test data on ".localtime()."\n") x length($file);
52          ok($sth->execute($file,$file_data{$file}), "insert $file");          ok($sth_insert->execute($file,$file_data{$file}), "insert $file");
53  }  }
54    
 ok($dbh->disconnect, "disconnect after insert");  
   
55  my $sql_filenames = qq{  my $sql_filenames = qq{
56          select          select
57                  name as id,                  name as id,
# Line 91  sub test_file { Line 93  sub test_file {
93    
94          return unless (-f $f);          return unless (-f $f);
95    
96          ok(open(F, $f), "open");          ok(open(F, $f), "open read $f");
97          my $tmp = '';          my $tmp = '';
98          while(<F>) {          while(<F>) {
99                  $tmp .= $_;                  $tmp .= $_;
# Line 105  sub test_file { Line 107  sub test_file {
107    
108          cmp_ok(length($file_data{$f}), '==', length($tmp), "size");          cmp_ok(length($file_data{$f}), '==', length($tmp), "size");
109          cmp_ok($file_data{$f}, 'eq', $tmp, "content");          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  # small delay so that filesystem could mount
# Line 114  find({ wanted => \&test_file, no_chdir = Line 126  find({ wanted => \&test_file, no_chdir =
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.58  
changed lines
  Added in v.59

  ViewVC Help
Powered by ViewVC 1.1.26