From: Arthur Axel 'fREW' Schmidt Date: Tue, 23 Feb 2010 05:05:19 +0000 (-0600) Subject: test upgrade_single_step X-Git-Tag: v0.001000_01~146 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4ea147c61b35f316efb6482e4becf4b5bfcff312;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git test upgrade_single_step --- diff --git a/lib/DBIx/Class/DeploymentHandler.pm b/lib/DBIx/Class/DeploymentHandler.pm index 0c584aa..4d9fc13 100644 --- a/lib/DBIx/Class/DeploymentHandler.pm +++ b/lib/DBIx/Class/DeploymentHandler.pm @@ -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', ); diff --git a/t/02-instantiation.t b/t/02-instantiation.t index c4b4239..b4da432 100644 --- a/t/02-instantiation.t +++ b/t/02-instantiation.t @@ -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 diff --git a/t/lib/DBICVersion_v2.pm b/t/lib/DBICVersion_v2.pm index fa7932b..659e3b6 100644 --- a/t/lib/DBICVersion_v2.pm +++ b/t/lib/DBICVersion_v2.pm @@ -17,7 +17,8 @@ __PACKAGE__->add_columns( }, baz => { data_type => 'VARCHAR', - size => '10' + size => '10', + is_nullable => 1, }, ); diff --git a/t/lib/DBICVersion_v3.pm b/t/lib/DBICVersion_v3.pm index eb11caa..3d614db 100644 --- a/t/lib/DBICVersion_v3.pm +++ b/t/lib/DBICVersion_v3.pm @@ -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, }, );