60ca5845300155189e1dfbc01c9843bd3f412149
[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 aliased
8   'DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions';
9
10 {
11   my $vh = DatabaseToSchemaVersions->new({
12     to_version => '5.0',
13     database_version => '1.0',
14     schema_version => '1.0',
15   });
16
17   ok( $vh, 'VersionHandler gets instantiated' );
18   ok(
19     eq_array( $vh->next_version_set, [qw( 1.0 5.0 )] ),
20     'db version and to_version get correctly put into version set'
21   );
22   ok( !$vh->next_version_set, 'next_version_set only works once');
23   ok( !$vh->next_version_set, 'seriously.');
24 }
25
26 {
27   my $vh = DatabaseToSchemaVersions->new({
28     database_version => '1.0',
29     schema_version => '1.0',
30   });
31
32   ok( $vh, 'VersionHandler gets instantiated' );
33   ok(
34     !$vh->next_version_set,
35     'VersionHandler is null when schema_version and db_verison are the same'
36   );
37 }
38
39 {
40   my $vh = DatabaseToSchemaVersions->new({
41     database_version => '1.0',
42     schema_version => '1.0',
43   });
44
45   ok( $vh, 'VersionHandler gets instantiated' );
46   ok(
47     !$vh->next_version_set,
48     'VersionHandler is null when schema_version and db_verison are the same'
49   );
50 }
51
52 {
53   my $vh = DatabaseToSchemaVersions->new({
54     database_version => '1.0',
55     schema_version => '10.0',
56   });
57
58   ok( $vh, 'VersionHandler gets instantiated' );
59   ok(
60     eq_array( $vh->next_version_set, [qw( 1.0 10.0 )] ),
61     'db version and schema version get correctly put into version set'
62   );
63   ok( !$vh->next_version_set, 'VersionHandler is null on next try' );
64 }
65
66 done_testing;
67 # vim: ts=2 sw=2 expandtab