X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F02-instantiation.t;h=8536937224b4cca41508361d4b06a19560aa60ff;hb=24794769393e7e30c827e1010c5e23f7a9a58657;hp=57e141a82dbee64cef9d4a67d3713552d510f239;hpb=b9c4146b78c5485de4c363de99e24dd1994f7627;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git diff --git a/t/02-instantiation.t b/t/02-instantiation.t index 57e141a..8536937 100644 --- a/t/02-instantiation.t +++ b/t/02-instantiation.t @@ -7,25 +7,31 @@ use lib 't/lib'; use DBICTest; use DBIx::Class::DeploymentHandler; my $db = 'dbi:SQLite:db.db'; +my @connection = ($db, '', '', { ignore_version => 1 }); my $sql_dir = 't/sql'; unlink 'db.db' if -e 'db.db'; -mkdir 't/sql' unless -d 't/sql'; +if (-d 't/sql') { + unlink $_ for glob('t/sql/*'); +} else { + mkdir 't/sql'; +} VERSION1: { use_ok 'DBICVersion_v1'; - my $s = DBICVersion::Schema->connect($db); + my $s = DBICVersion::Schema->connect(@connection); ok($s, 'DBICVersion::Schema 1.0 instantiates correctly'); my $handler = DBIx::Class::DeploymentHandler->new({ upgrade_directory => $sql_dir, schema => $s, - databases => ['SQLite'], + databases => 'SQLite', + sqltargs => { add_drop_table => 0 }, }); ok($handler, 'DBIx::Class::DeploymentHandler w/1.0 instantiates correctly'); my $version = $s->schema_version(); - $handler->create_ddl_dir( $version, 0); + $handler->create_install_ddl(); ok(-e 't/sql/DBICVersion-Schema-1.0-SQLite.sql', 'DDL for 1.0 got created successfully'); dies_ok { @@ -43,19 +49,19 @@ VERSION1: { VERSION2: { use_ok 'DBICVersion_v2'; - my $s = DBICVersion::Schema->connect($db); + my $s = DBICVersion::Schema->connect(@connection); ok($s, 'DBICVersion::Schema 2.0 instantiates correctly'); my $handler = DBIx::Class::DeploymentHandler->new({ upgrade_directory => $sql_dir, schema => $s, - databases => ['SQLite'], + databases => 'SQLite', }); ok($handler, 'DBIx::Class::DeploymentHandler w/2.0 instantiates correctly'); $version = $s->schema_version(); - $handler->create_ddl_dir($version, 0); - $handler->create_ddl_dir($version, '1.0'); + $handler->create_install_ddl(); + $handler->create_update_ddl($version, '1.0'); ok(-e 't/sql/DBICVersion-Schema-2.0-SQLite.sql', 'DDL for 2.0 got created successfully'); ok(-e 't/sql/DBICVersion-Schema-1.0-2.0-SQLite.sql', 'DDL for migration from 1.0 to 2.0 got created successfully'); dies_ok { @@ -82,20 +88,20 @@ VERSION2: { VERSION3: { use_ok 'DBICVersion_v3'; - my $s = DBICVersion::Schema->connect($db); + my $s = DBICVersion::Schema->connect(@connection); ok($s, 'DBICVersion::Schema 3.0 instantiates correctly'); my $handler = DBIx::Class::DeploymentHandler->new({ upgrade_directory => $sql_dir, schema => $s, - databases => ['SQLite'], + databases => 'SQLite', }); ok($handler, 'DBIx::Class::DeploymentHandler w/3.0 instantiates correctly'); $version = $s->schema_version(); - $handler->create_ddl_dir( $version, 0); - $handler->create_ddl_dir( $version, '1.0'); - $handler->create_ddl_dir( $version, '2.0'); + $handler->create_install_ddl; + $handler->create_update_ddl( $version, '1.0'); + $handler->create_update_ddl( $version, '2.0'); ok(-e 't/sql/DBICVersion-Schema-3.0-SQLite.sql', 'DDL for 3.0 got created successfully'); ok(-e 't/sql/DBICVersion-Schema-1.0-3.0-SQLite.sql', 'DDL for migration from 1.0 to 3.0 got created successfully'); ok(-e 't/sql/DBICVersion-Schema-2.0-3.0-SQLite.sql', 'DDL for migration from 2.0 to 3.0 got created successfully'); @@ -119,4 +125,4 @@ VERSION3: { done_testing; __END__ -vim: ts=2,sw=2,expandtab +vim: ts=2 sw=2 expandtab