X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class-DeploymentHandler.git;a=blobdiff_plain;f=t%2Fversion_storages%2Fstandard.t;h=01bdb0ec2641a66d162e3aedba11cd16b225dada;hp=f714b6da4f570b765c454af12676ab6e174bc82f;hb=f3b5161e466df2a94f2704177f0173e7d940c4d5;hpb=c8a2f7bdc9ccae19e779705651dd16241213eb9d diff --git a/t/version_storages/standard.t b/t/version_storages/standard.t index f714b6d..01bdb0e 100644 --- a/t/version_storages/standard.t +++ b/t/version_storages/standard.t @@ -1,7 +1,9 @@ #!perl +use strict; +use warnings; + use Test::More; -use Test::Deep; use Test::Exception; use lib 't/lib'; @@ -11,76 +13,77 @@ use aliased 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator'; use DBICVersion_v1; use DBIx::Class::DeploymentHandler; -my $db = 'dbi:SQLite:db.db'; -my @connection = ($db, '', '', { ignore_version => 1 }); +my $dbh = DBICDHTest::dbh(); +my @connection = (sub { $dbh }, { ignore_version => 1 }); my $sql_dir = 't/sql'; my $s = DBICVersion::Schema->connect(@connection); { - my $warning; - local $SIG{__WARN__} = sub {$warning = shift}; - my $t = DBICVersion::Schema->connect('frewfrew', '', ''); - like( $warning, qr/Your DB is currently unversioned. Please call upgrade on your schema to sync the DB/, 'warning when database is unversioned'); + my $warning; + local $SIG{__WARN__} = sub {$warning = shift}; + my $t = DBICVersion::Schema->connect('frewfrew', '', ''); + like( $warning, qr/Your DB is currently unversioned. Please call upgrade on your schema to sync the DB/, 'warning when database is unversioned'); } DBICDHTest::ready; my $dm = Translator->new({ - schema => $s, - upgrade_directory => $sql_dir, - databases => ['SQLite'], - sqltargs => { add_drop_table => 0 }, + schema => $s, + script_directory => $sql_dir, + databases => ['SQLite'], + sql_translator_args => { add_drop_table => 0 }, }); my $vs = Standard->new({ schema => $s }); -$dm->prepare_resultsource_install( - $vs->version_rs->result_source -); +$dm->prepare_resultsource_install({ + result_source => $vs->version_rs->result_source +}); ok( $vs, 'DBIC::DH::VersionStorage::Standard instantiates correctly' ); ok( !$vs->version_storage_is_installed, 'VersionStorage is not yet installed' ); -$dm->install_resultsource( - $vs->version_rs->result_source, - '1.0', -); +$dm->install_resultsource({ + result_source => $vs->version_rs->result_source, + version => '1.0', +}); ok( $vs->version_storage_is_installed, 'VersionStorage is now installed' ); $vs->add_database_version({ - version => '1.0', + version => '1.0', }); ok( - eq_array( - [ $vs->version_rs->search(undef, {order_by => 'id'})->get_column('version')->all], - [ '1.0' ], - ), - 'initial version works correctly' + eq_array( + [ $vs->version_rs->search(undef, {order_by => 'id'})->get_column('version')->all], + [ '1.0' ], + ), + 'initial version works correctly' ); is( $vs->database_version, '1.0', 'database version is 1.0'); $vs->add_database_version({ - version => '2.0', + version => '2.0', }); is( $vs->database_version, '2.0', 'database version is 2.0'); ok( - eq_array( - [ $vs->version_rs->search(undef, {order_by => 'id'})->get_column('version')->all], - [ '1.0', '2.0', ], - ), - 'adding another version works correctly' + eq_array( + [ $vs->version_rs->search(undef, {order_by => 'id'})->get_column('version')->all], + [ '1.0', '2.0', ], + ), + 'adding another version works correctly' ); +my $u; { - my $warning; - local $SIG{__WARN__} = sub {$warning = shift}; - my $u = DBICVersion::Schema->connect($db, '', ''); - like( $warning, qr/Versions out of sync. This is 1.0, your database contains version 2.0, please call upgrade on your Schema./, 'warning when database/schema mismatch'); + my $warning; + local $SIG{__WARN__} = sub {$warning = shift}; + $u = DBICVersion::Schema->connect(sub { $dbh }); + like( $warning, qr/Versions out of sync. This is 1\.0, your database contains version 2\.0, please call upgrade on your Schema\./, 'warning when database/schema mismatch'); }