stub tests for all classes
[dbsrgits/DBIx-Class-DeploymentHandler.git] / t / version_handlers / db_schema_versions.t
1 #!perl
2
3 use Test::More;
4 use Test::Exception;
5
6 use lib 't/lib';
7 use DBICDHTest;
8 use DBICTest;
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';
14
15 DBICDHTest::ready;
16
17 use DBICVersion_v1;
18 my $s = DBICVersion::Schema->connect(@connection);
19
20 my $handler = DBIx::Class::DeploymentHandler->new({
21    upgrade_directory => $sql_dir,
22    schema => $s,
23    databases => 'SQLite',
24  sqltargs => { add_drop_table => 0 },
25 });
26 my $v_storage = $handler->version_storage;
27 my $version = $s->schema_version();
28 $handler->prepare_install();
29
30 $handler->install;
31 {
32   my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({
33     schema => $s,
34     ordered_versions => $versions,
35     to_version => '5.0',
36     version_storage => $v_storage,
37   });
38
39   ok( $vh, 'VersionHandler gets instantiated' );
40   ok( eq_array( $vh->next_version_set, [qw( 1.0 5.0 )] ), 'db version and to_version get correctly put into version set');
41   ok( !$vh->next_version_set, 'next_version_set only works once');
42   ok( !$vh->next_version_set, 'seriously.');
43 }
44
45 {
46   my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({
47     schema => $s,
48     ordered_versions => $versions,
49     version_storage => $v_storage,
50   });
51
52   ok( $vh, 'VersionHandler gets instantiated' );
53   ok( !$vh->next_version_set, 'VersionHandler is null when schema_version and db_verison are the same' );
54 }
55
56 {
57   my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({
58     schema => $s,
59     ordered_versions => $versions,
60     version_storage => $v_storage,
61   });
62
63   ok( $vh, 'VersionHandler gets instantiated' );
64   ok( !$vh->next_version_set, 'VersionHandler is null when schema_version and db_verison are the same' );
65 }
66
67 {
68   $DBICVersion::Schema::VERSION = '10.0';
69
70   my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({
71     schema => $s,
72     ordered_versions => $versions,
73     version_storage => $v_storage,
74   });
75
76   ok( $vh, 'VersionHandler gets instantiated' );
77   ok( eq_array( $vh->next_version_set, [qw( 1.0 10.0 )] ), 'db version and schema version get correctly put into version set');
78   ok( !$vh->next_version_set, 'VersionHandler is null on next try' );
79 }
80
81 done_testing;
82 __END__
83
84 vim: ts=2 sw=2 expandtab