X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fversion_handlers%2Fdb_schema_versions.t;h=7a5e62a817e69d8b8e5d94291e01a2bec2e7e6f7;hb=b539a2166a39a25bb3d1d91b47909500b55b3ee6;hp=1c5d394287e1563bf7dac8dc4199e40ebd067fa9;hpb=d53e0bfc728d1d5551bbbe840a4c761ef3e33a60;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git diff --git a/t/version_handlers/db_schema_versions.t b/t/version_handlers/db_schema_versions.t index 1c5d394..7a5e62a 100644 --- a/t/version_handlers/db_schema_versions.t +++ b/t/version_handlers/db_schema_versions.t @@ -6,79 +6,64 @@ use Test::Exception; use lib 't/lib'; use DBICDHTest; use DBICTest; -use DBIx::Class::DeploymentHandler; -use DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions; -my $db = 'dbi:SQLite:db.db'; -my @connection = ($db, '', '', { ignore_version => 1 }); -my $sql_dir = 't/sql'; +use aliased + 'DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions'; -DBICDHTest::ready; - -use DBICVersion_v1; -my $s = DBICVersion::Schema->connect(@connection); - -my $handler = DBIx::Class::DeploymentHandler->new({ - upgrade_directory => $sql_dir, - schema => $s, - databases => 'SQLite', - sqltargs => { add_drop_table => 0 }, -}); -my $v_storage = $handler->version_storage; -my $version = $s->schema_version(); -$handler->prepare_install(); - -$handler->install; { - my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({ - schema => $s, - ordered_versions => $versions, + my $vh = DatabaseToSchemaVersions->new({ to_version => '5.0', - version_storage => $v_storage, + database_version => '1.0', + schema_version => '1.0', }); ok( $vh, 'VersionHandler gets instantiated' ); - ok( eq_array( $vh->next_version_set, [qw( 1.0 5.0 )] ), 'db version and to_version get correctly put into version set'); + ok( + eq_array( $vh->next_version_set, [qw( 1.0 5.0 )] ), + 'db version and to_version get correctly put into version set' + ); ok( !$vh->next_version_set, 'next_version_set only works once'); ok( !$vh->next_version_set, 'seriously.'); } { - my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({ - schema => $s, - ordered_versions => $versions, - version_storage => $v_storage, + my $vh = DatabaseToSchemaVersions->new({ + database_version => '1.0', + schema_version => '1.0', }); ok( $vh, 'VersionHandler gets instantiated' ); - ok( !$vh->next_version_set, 'VersionHandler is null when schema_version and db_verison are the same' ); + ok( + !$vh->next_version_set, + 'VersionHandler is null when schema_version and db_verison are the same' + ); } { - my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({ - schema => $s, - ordered_versions => $versions, - version_storage => $v_storage, + my $vh = DatabaseToSchemaVersions->new({ + database_version => '1.0', + schema_version => '1.0', }); ok( $vh, 'VersionHandler gets instantiated' ); - ok( !$vh->next_version_set, 'VersionHandler is null when schema_version and db_verison are the same' ); + ok( + !$vh->next_version_set, + 'VersionHandler is null when schema_version and db_verison are the same' + ); } { - $DBICVersion::Schema::VERSION = '10.0'; - - my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({ - schema => $s, - ordered_versions => $versions, - version_storage => $v_storage, + my $vh = DatabaseToSchemaVersions->new({ + database_version => '1.0', + schema_version => '10.0', }); ok( $vh, 'VersionHandler gets instantiated' ); - ok( eq_array( $vh->next_version_set, [qw( 1.0 10.0 )] ), 'db version and schema version get correctly put into version set'); + ok( + eq_array( $vh->next_version_set, [qw( 1.0 10.0 )] ), + 'db version and schema version get correctly put into version set' + ); ok( !$vh->next_version_set, 'VersionHandler is null on next try' ); } done_testing; -__END__ - -vim: ts=2 sw=2 expandtab +# vim: ts=2 sw=2 expandtab