X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fversion_handlers%2Fdb_schema_versions.t;h=60ca5845300155189e1dfbc01c9843bd3f412149;hb=764492e328b24c54422291b6268e370ce63cb46e;hp=1c5d394287e1563bf7dac8dc4199e40ebd067fa9;hpb=02d58ac05dd4ccbe5fd4ff8a9cc58681ee1b74ee;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..60ca584 100644 --- a/t/version_handlers/db_schema_versions.t +++ b/t/version_handlers/db_schema_versions.t @@ -4,81 +4,64 @@ use Test::More; 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