[Bast-commits] r9190 - in DBIx-Class/0.08/trunk: lib/DBIx/Class/Storage t/storage

rbuels at dev.catalyst.perl.org rbuels at dev.catalyst.perl.org
Tue Apr 20 19:12:22 GMT 2010


Author: rbuels
Date: 2010-04-20 20:12:22 +0100 (Tue, 20 Apr 2010)
New Revision: 9190

Added:
   DBIx-Class/0.08/trunk/t/storage/deploy.t
Modified:
   DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
Log:
create_ddl_dir mkpaths its dir if necessary.  also, added storage/deploy.t as place to put deployment tests

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm	2010-04-20 15:33:12 UTC (rev 9189)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm	2010-04-20 19:12:22 UTC (rev 9190)
@@ -16,6 +16,8 @@
 use Data::Dumper::Concise();
 use Sub::Name ();
 
+use File::Path ();
+
 __PACKAGE__->mk_group_accessors('simple' =>
   qw/_connect_info _dbi_connect_info _dbh _sql_maker _sql_maker_opts _conn_pid
      _conn_tid transaction_depth _dbh_autocommit _driver_determined savepoints
@@ -2334,6 +2336,9 @@
   unless ($dir) {
     carp "No directory given, using ./\n";
     $dir = './';
+  } else {
+      -d $dir or File::Path::mkpath($dir)
+          or croak "create_ddl_dir: could not create dir '$dir'";
   }
 
   $self->throw_exception ("Directory '$dir' does not exist\n") unless(-d $dir);

Added: DBIx-Class/0.08/trunk/t/storage/deploy.t
===================================================================
--- DBIx-Class/0.08/trunk/t/storage/deploy.t	                        (rev 0)
+++ DBIx-Class/0.08/trunk/t/storage/deploy.t	2010-04-20 19:12:22 UTC (rev 9190)
@@ -0,0 +1,32 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+use lib qw(t/lib);
+use DBICTest;
+
+use File::Spec;
+use File::Path qw/ mkpath rmtree /;
+
+
+my $schema = DBICTest->init_schema();
+
+my $var = File::Spec->catfile(qw| t var create_ddl_dir |);
+-d $var
+    or mkpath($var)
+    or die "can't create $var";
+
+my $test_dir_1 =  File::Spec->catdir( $var, 'test1', 'foo', 'bar' );
+rmtree( $test_dir_1 ) if -d $test_dir_1;
+$schema->create_ddl_dir( undef, undef, $test_dir_1 );
+
+ok( -d $test_dir_1, 'create_ddl_dir did a mkpath on its target dir' );
+ok( scalar( glob $test_dir_1.'/*.sql' ), 'there are sql files in there' );
+
+TODO: {
+    local $TODO = 'we should probably add some tests here for actual deployability of the DDL?';
+    ok( 0 );
+}
+
+done_testing;




More information about the Bast-commits mailing list