VersionHandler no longer needs access to other components, *much* cleaner tests for...
[dbsrgits/DBIx-Class-DeploymentHandler.git] / t / version_handlers / explict_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::ExplicitVersions';
9
10 my $versions = [map "$_.0", 0..100];
11
12 {
13   my $vh = ExplicitVersions->new({
14     ordered_versions => $versions,
15     to_version => '1.0',
16     schema_version => '1.0',
17     database_version => '1.0',
18   });
19
20   ok $vh, 'VersionHandler gets instantiated';
21
22   ok(
23     !$vh->next_version_set,
24     'next version set returns undef if we are at the version requested'
25   );
26 }
27
28 {
29   my $vh = ExplicitVersions->new({
30     ordered_versions => $versions,
31     to_version => '5.0',
32     schema_version => '1.0',
33     database_version => '1.0',
34   });
35
36   ok $vh, 'VersionHandler gets instantiated';
37   ok(
38     eq_array($vh->next_version_set, [qw( 1.0 2.0 )]),
39     'first version pair works'
40   );
41   ok(
42     eq_array($vh->next_version_set, [qw( 2.0 3.0 )]),
43     'second version pair works'
44   );
45   ok(
46     eq_array($vh->next_version_set, [qw( 3.0 4.0 )]),
47     'third version pair works'
48   );
49   ok(
50     eq_array($vh->next_version_set, [qw( 4.0 5.0 )]),
51     'fourth version pair works'
52   );
53   ok( !$vh->next_version_set, 'no more versions after final pair' );
54   ok( !$vh->next_version_set, 'still no more versions after final pair' );
55 }
56
57 dies_ok {
58   my $vh = ExplicitVersions->new({
59     ordered_versions => $versions,
60     to_version => '0.0',
61     schema_version => '1.0',
62     database_version => '1.0',
63   });
64 } 'cannot request a version before the current version';
65
66 done_testing;
67 #vim: ts=2 sw=2 expandtab