test upgrade_single_step
Arthur Axel 'fREW' Schmidt [Tue, 23 Feb 2010 05:05:19 +0000 (23:05 -0600)]
lib/DBIx/Class/DeploymentHandler.pm
t/02-instantiation.t
t/lib/DBICVersion_v2.pm
t/lib/DBICVersion_v3.pm

index 0c584aa..4d9fc13 100644 (file)
@@ -11,14 +11,14 @@ has schema => (
   isa      => 'DBIx::Class::Schema',
   is       => 'ro',
   required => 1,
-  handles => [qw( schema_version )],
+  handles => [qw( ddl_filename schema_version )],
 );
 
 has upgrade_directory => (
   isa      => 'Str',
   is       => 'ro',
   required => 1,
-  default  => 'upgrades',
+  default  => 'sql',
 );
 
 has backup_directory => (
@@ -39,7 +39,7 @@ method _build_storage {
 }
 
 has _filedata => (
-  isa => 'Str',
+  isa => 'ArrayRef[Str]',
   is  => 'rw',
 );
 
index c4b4239..b4da432 100644 (file)
@@ -6,14 +6,15 @@ use Test::Exception;
 use lib 't/lib';
 use DBICTest;
 use DBIx::Class::DeploymentHandler;
-
+my $db = 'dbi:SQLite:db.db';
 my $sql_dir = 't/sql';
 
 VERSION1: {
        use_ok 'DBICVersion_v1';
-       my $s = DBICVersion::Schema->connect('dbi:SQLite::memory:');
+       my $s = DBICVersion::Schema->connect($db);
        ok($s, 'DBICVersion::Schema 1.0 instantiates correctly');
        my $handler = DBIx::Class::DeploymentHandler->new({
+               upgrade_directory => $sql_dir,
                schema => $s,
        });
 
@@ -38,9 +39,10 @@ VERSION1: {
 
 VERSION2: {
        use_ok 'DBICVersion_v2';
-       my $s = DBICVersion::Schema->connect('dbi:SQLite::memory:');
+       my $s = DBICVersion::Schema->connect($db);
        ok($s, 'DBICVersion::Schema 2.0 instantiates correctly');
        my $handler = DBIx::Class::DeploymentHandler->new({
+               upgrade_directory => $sql_dir,
                schema => $s,
        });
 
@@ -57,7 +59,14 @@ VERSION2: {
                        baz => 'frew',
                })
        } 'schema not deployed';
-       $handler->install;
+       #$handler->install('1.0');
+       dies_ok {
+               $s->resultset('Foo')->create({
+                       bar => 'frew',
+                       baz => 'frew',
+               })
+       } 'schema not uppgrayyed';
+       $handler->upgrade_single_step('1.0', '2.0');
        lives_ok {
                $s->resultset('Foo')->create({
                        bar => 'frew',
@@ -68,9 +77,10 @@ VERSION2: {
 
 VERSION3: {
        use_ok 'DBICVersion_v3';
-       my $s = DBICVersion::Schema->connect('dbi:SQLite::memory:');
+       my $s = DBICVersion::Schema->connect($db);
        ok($s, 'DBICVersion::Schema 3.0 instantiates correctly');
        my $handler = DBIx::Class::DeploymentHandler->new({
+               upgrade_directory => $sql_dir,
                schema => $s,
        });
 
@@ -85,12 +95,12 @@ VERSION3: {
        ok(-e 't/sql/DBICVersion-Schema-2.0-3.0-SQLite.sql', 'DDL for migration from 2.0 to 3.0 got created successfully');
        dies_ok {
                $s->resultset('Foo')->create({
-                       bar => 'frew',
-                       baz => 'frew',
-                       biff => 'frew',
-               })
+                               bar => 'frew',
+                               baz => 'frew',
+                               biff => 'frew',
+                       })
        } 'schema not deployed';
-       $handler->install;
+       $handler->upgrade_single_step('2.0', '3.0');
        lives_ok {
                $s->resultset('Foo')->create({
                        bar => 'frew',
@@ -101,3 +111,6 @@ VERSION3: {
 }
 
 done_testing;
+__END__
+
+vim: ts=2,sw=2,expandtab
index fa7932b..659e3b6 100644 (file)
@@ -17,7 +17,8 @@ __PACKAGE__->add_columns(
        },
        baz => {
                data_type => 'VARCHAR',
-               size => '10'
+               size => '10',
+               is_nullable => 1,
        },
 );
 
index eb11caa..3d614db 100644 (file)
@@ -17,11 +17,13 @@ __PACKAGE__->add_columns(
        },
        baz => {
                data_type => 'VARCHAR',
-               size => '10'
+               size => '10',
+               is_nullable => 1,
        },
        biff => {
                data_type => 'VARCHAR',
-               size => '10'
+               size => '10',
+               is_nullable => 1,
        },
 );