8 use DBIx::Class::DeploymentHandler;
9 use DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions;
10 my $db = 'dbi:SQLite:db.db';
11 my @connection = ($db, '', '', { ignore_version => 1 });
12 my $sql_dir = 't/sql';
14 unlink 'db.db' if -e 'db.db';
16 unlink $_ for glob('t/sql/*');
22 my $s = DBICVersion::Schema->connect(@connection);
24 my $handler = DBIx::Class::DeploymentHandler->new({
25 upgrade_directory => $sql_dir,
27 databases => 'SQLite',
28 sqltargs => { add_drop_table => 0 },
30 my $v_storage = $handler->version_storage;
31 my $version = $s->schema_version();
32 $handler->prepare_install();
36 my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({
38 ordered_versions => $versions,
40 version_storage => $v_storage,
43 ok( $vh, 'VersionHandler gets instantiated' );
44 ok( eq_array( $vh->next_version_set, [qw( 1.0 5.0 )] ), 'db version and to_version get correctly put into version set');
45 ok( !$vh->next_version_set, 'next_version_set only works once');
46 ok( !$vh->next_version_set, 'seriously.');
50 my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({
52 ordered_versions => $versions,
53 version_storage => $v_storage,
56 ok( $vh, 'VersionHandler gets instantiated' );
57 ok( !$vh->next_version_set, 'VersionHandler is null when schema_version and db_verison are the same' );
61 my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({
63 ordered_versions => $versions,
64 version_storage => $v_storage,
67 ok( $vh, 'VersionHandler gets instantiated' );
68 ok( !$vh->next_version_set, 'VersionHandler is null when schema_version and db_verison are the same' );
72 $DBICVersion::Schema::VERSION = '10.0';
74 my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({
76 ordered_versions => $versions,
77 version_storage => $v_storage,
80 ok( $vh, 'VersionHandler gets instantiated' );
81 ok( eq_array( $vh->next_version_set, [qw( 1.0 10.0 )] ), 'db version and schema version get correctly put into version set');
82 ok( !$vh->next_version_set, 'VersionHandler is null on next try' );
88 vim: ts=2 sw=2 expandtab