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 },
31 my $v_storage = $handler->version_storage;
33 my $version = $s->schema_version();
34 $handler->prepare_install();
38 my $versions = [map "$_.0", 0..100];
41 my $vh = DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions->new({
43 ordered_versions => $versions,
45 version_storage => $v_storage,
48 ok $vh, 'VersionHandler gets instantiated';
50 ok( !$vh->next_version_set, 'next version set returns undef if we are at the version requested' );
54 my $vh = DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions->new({
56 ordered_versions => $versions,
58 version_storage => $v_storage,
61 ok $vh, 'VersionHandler gets instantiated';
62 ok( eq_array($vh->next_version_set, [qw( 1.0 2.0 )]), 'first version pair works' );
63 ok( eq_array($vh->next_version_set, [qw( 2.0 3.0 )]), 'second version pair works' );
64 ok( eq_array($vh->next_version_set, [qw( 3.0 4.0 )]), 'third version pair works' );
65 ok( eq_array($vh->next_version_set, [qw( 4.0 5.0 )]), 'fourth version pair works' );
66 ok( !$vh->next_version_set, 'no more versions after final pair' );
67 ok( !$vh->next_version_set, 'still no more versions after final pair' );
71 my $vh = DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions->new({
73 ordered_versions => $versions,
75 version_storage => $v_storage,
77 } 'cannot request a version before the current version';
82 vim: ts=2 sw=2 expandtab