9 use DBIx::Class::DeploymentHandler;
10 use DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions;
11 my $db = 'dbi:SQLite:db.db';
12 my @connection = ($db, '', '', { ignore_version => 1 });
13 my $sql_dir = 't/sql';
18 my $s = DBICVersion::Schema->connect(@connection);
20 my $handler = DBIx::Class::DeploymentHandler->new({
21 upgrade_directory => $sql_dir,
23 databases => 'SQLite',
24 sqltargs => { add_drop_table => 0 },
27 my $v_storage = $handler->version_storage;
29 my $version = $s->schema_version();
30 $handler->prepare_install();
34 my $versions = [map "$_.0", 0..100];
37 my $vh = DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions->new({
39 ordered_versions => $versions,
41 version_storage => $v_storage,
44 ok $vh, 'VersionHandler gets instantiated';
46 ok( !$vh->next_version_set, 'next version set returns undef if we are at the version requested' );
50 my $vh = DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions->new({
52 ordered_versions => $versions,
54 version_storage => $v_storage,
57 ok $vh, 'VersionHandler gets instantiated';
58 ok( eq_array($vh->next_version_set, [qw( 1.0 2.0 )]), 'first version pair works' );
59 ok( eq_array($vh->next_version_set, [qw( 2.0 3.0 )]), 'second version pair works' );
60 ok( eq_array($vh->next_version_set, [qw( 3.0 4.0 )]), 'third version pair works' );
61 ok( eq_array($vh->next_version_set, [qw( 4.0 5.0 )]), 'fourth version pair works' );
62 ok( !$vh->next_version_set, 'no more versions after final pair' );
63 ok( !$vh->next_version_set, 'still no more versions after final pair' );
67 my $vh = DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions->new({
69 ordered_versions => $versions,
71 version_storage => $v_storage,
73 } 'cannot request a version before the current version';
78 vim: ts=2 sw=2 expandtab