test fixin
[dbsrgits/DBIx-Class-Fixtures.git] / t / lib / DBICTest.pm
index a0414cf..08c0e27 100755 (executable)
@@ -97,11 +97,20 @@ sub deploy_schema {
     my $schema = shift;
 
     my $file = shift || $self->get_ddl_file($schema);
-    open IN, $file;
+    open(  my $fh, "<",$file ) or die "couldnt open $file, $!";
     my $sql;
-    { local $/ = undef; $sql = <IN>; }
-    close IN;
-    ($schema->storage->dbh->do($_) || print "Error on SQL: $_\n") for split(/;\n/, $sql);
+    { local $/ = undef; $sql = <$fh>; }
+
+    foreach my $line (split(/;\n/, $sql)) {
+      print "$line\n";
+      next if(!$line);
+      next if($line =~ /^--/);
+      next if($line =~ /^BEGIN TRANSACTION/m);
+      next if($line =~ /^COMMIT/m);
+      next if $line =~ /^\s+$/; # skip whitespace only
+
+      $schema->storage->dbh->do($line) || print "Error on SQL: $line\n";
+    }
 }
  
 
@@ -139,6 +148,8 @@ sub populate_schema {
         [ 1, 'Caterwauler McCrae' ],
         [ 2, 'Random Boy Band' ],
         [ 3, 'We Are Goth' ],
+        [ 4, '' ], # Test overridden new will default name to "Test Name" using use_create => 1.
+        [ 32948, 'Big PK' ],
     ]);
 
     $schema->populate('CD', [