use coderef instead of run method
[dbsrgits/DBIx-Class-DeploymentHandler.git] / t / deploy_methods / sql_translator.t
index eca08c8..ad95bab 100644 (file)
@@ -22,17 +22,27 @@ VERSION1: {
       schema            => $s,
       upgrade_directory => $sql_dir,
       databases         => ['SQLite'],
-      sqltargs          => { add_drop_table => 0 },
+      sql_translator_args          => { add_drop_table => 0 },
    });
 
    ok( $dm, 'DBIC::DH::DM::SQL::Translator gets instantiated correctly' );
 
-   $dm->prepare_install;
+   $dm->prepare_deploy;
+
+   mkpath(catfile(qw( t sql SQLite preinstall 1.0 )));
+   open my $prerun, '>',
+      catfile(qw( t sql SQLite preinstall 1.0 003-semiautomatic.pl ));
+   print {$prerun} "sub {use File::Touch; touch(q(foobar));}";
+   close $prerun;
+   $dm->preinstall_scripts('1.0');
+
+   ok -e 'foobar';
+
    {
       my $warned = 0;
       local $SIG{__WARN__} = sub{$warned = 1};
-      $dm->prepare_install;
-      ok( $warned, 'prepare_install warns if you run it twice' );
+      $dm->prepare_deploy;
+      ok( $warned, 'prepare_deploy warns if you run it twice' );
    }
    mkpath(catfile(qw( t sql _common schema 1.0 )));
    open my $common, '>',
@@ -52,7 +62,7 @@ VERSION1: {
    } 'schema not deployed';
 
    mkpath catfile(qw( t sql _common schema 1.0 ));
-   open my $common, '>',
+   open $common, '>',
       catfile(qw( t sql _common schema 1.0 001-auto.sql ));
    print {$common} qq<This will never get run>;
    close $common;
@@ -77,14 +87,14 @@ VERSION2: {
       schema            => $s,
       upgrade_directory => $sql_dir,
       databases         => ['SQLite'],
-      sqltargs          => { add_drop_table => 0 },
-               txn_wrap          => 1,
+      sql_translator_args          => { add_drop_table => 0 },
+      txn_wrap          => 1,
    });
 
    ok( $dm, 'DBIC::DH::SQL::Translator w/2.0 instantiates correctly');
 
    $version = $s->schema_version();
-   $dm->prepare_install;
+   $dm->prepare_deploy;
    ok(
       -f catfile(qw( t sql SQLite schema 2.0 001-auto.sql )),
       '2.0 schema gets generated properly'
@@ -130,14 +140,14 @@ VERSION2: {
    open my $common_pl, '>',
       catfile(qw( t sql _common up 1.0-2.0 003-semiautomatic.pl ));
    print {$common_pl} q|
-               sub run {
-                       my $schema = shift;
-                       $schema->resultset('Foo')->create({
-                               bar => 'goodbye',
-                               baz => 'blue skies',
-                       })
-               }
-       |;
+      sub {
+         my $schema = shift;
+         $schema->resultset('Foo')->create({
+            bar => 'goodbye',
+            baz => 'blue skies',
+         })
+      }
+   |;
    close $common_pl;
 
    $dm->upgrade_single_step([qw( 1.0 2.0 )]);
@@ -161,7 +171,7 @@ VERSION2: {
          bar => 'frew',
          baz => 'frew',
       })
-   } 'schema is downpgrayyed';
+   } 'schema is downgrayyed';
    $dm->upgrade_single_step([qw( 1.0 2.0 )]);
 }
 
@@ -172,14 +182,14 @@ VERSION3: {
       schema            => $s,
       upgrade_directory => $sql_dir,
       databases         => ['SQLite'],
-      sqltargs          => { add_drop_table => 0 },
+      sql_translator_args          => { add_drop_table => 0 },
       txn_wrap          => 0,
    });
 
    ok( $dm, 'DBIC::DH::SQL::Translator w/3.0 instantiates correctly');
 
    $version = $s->schema_version();
-   $dm->prepare_install;
+   $dm->prepare_deploy;
    ok(
       -f catfile(qw( t sql SQLite schema 3.0 001-auto.sql )),
       '2.0 schema gets generated properly'