Author: REHSACK
Date: Fri Jun 4 04:13:59 2010
New Revision: 14098
Modified:
dbi/trunk/t/49dbd_file.t
Log:
Add test to prove fix for RT#58039
Modified: dbi/trunk/t/49dbd_file.t
==============================================================================
--- dbi/trunk/t/49dbd_file.t (original)
+++ dbi/trunk/t/49dbd_file.t Fri Jun 4 04:13:59 2010
@@ -3,6 +3,9 @@
use strict;
+use Cwd;
+use File::Path;
+use File::Spec;
use Test::More;
my $using_dbd_gofer = ($ENV{DBI_AUTOPROXY}||'') =~ /^dbi:Gofer.*transport=/i;
@@ -11,11 +14,16 @@
my $tbl;
BEGIN { $tbl = "db_". $$ . "_" };
-END { $tbl and unlink glob "${tbl}*" }
+#END { $tbl and unlink glob "${tbl}*" }
use_ok ("DBI");
use_ok ("DBD::File");
+my $dir = File::Spec->catdir(getcwd(),'test_output');
+
+rmtree $dir;
+mkpath $dir;
+
my $rowidx = 0;
my @rows = ( [ "Hello World" ], [ "Hello DBI Developers" ], );
@@ -40,9 +48,10 @@
my $encoding = "iso-8859-1";
+# now use dir to prove file existence
ok ($dbh = DBI->connect ("dbi:File:", undef, undef, {
- f_ext => ".txt/r",
- f_dir => ".",
+ f_ext => ".txt",
+ f_dir => $dir,
f_schema => undef,
f_encoding => $encoding,
f_lock => 0,
@@ -62,11 +71,32 @@
like ("@msg", qr{Cannot open .*/t_sbdgf_}, "Cannot open non-existing file");
}
+SKIP: {
+ my $fh;
+ my $tbl2 = $tbl . "2";
+
+ my $tbl2_file1 = File::Spec->catfile ($dir, "$tbl2.txt");
+ open $fh, ">", $tbl2_file1 or skip;
+ print $fh "You cannot read this anyway ...";
+ close $fh;
+
+ my $tbl2_file2 = File::Spec->catfile ($dir, "$tbl2");
+ open $fh, ">", $tbl2_file2 or skip;
+ print $fh "Neither that";
+ close $fh;
+
+ ok ($dbh->do ("drop table if exists $tbl2"), "drop manually created table $tbl2 (first file)");
+ ok (! -f $tbl2_file1, "$tbl2_file1 removed");
+ ok (-f $tbl2_file2, "$tbl2_file2 exists");
+ ok ($dbh->do ("drop table if exists $tbl2"), "drop manually created table $tbl2 (second file)");
+ ok (! -f $tbl2_file2, "$tbl2_file2 removed");
+ }
+
my @tfhl;
# Now test some basic SQL statements
-my $tbl_file = "$tbl.txt";
-ok ($dbh->do ("create table $tbl (txt varchar (20))"), "Create table $tbl");
+my $tbl_file = File::Spec->catfile ($dir, "$tbl.txt");
+ok ($dbh->do ("create table $tbl (txt varchar (20))"), "Create table $tbl") or diag $dbh->errstr;
ok (-f $tbl_file, "Test table exists");
# Expected: ("unix", "perlio", "encoding(iso-8859-1)")
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.