7 use Test::Fatal qw(lives_ok dies_ok);
11 'DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions';
13 my $versions = [map "$_.0", 0..100];
16 my $vh = ExplicitVersions->new({
17 ordered_versions => $versions,
18 schema_version => '2.0',
19 database_version => '1.0',
22 ok $vh, 'VersionHandler gets instantiated';
25 eq_array($vh->next_version_set, [qw( 1.0 2.0 )]),
26 'first version pair works'
29 !$vh->next_version_set,
30 'next version set returns undef when we are done'
35 my $vh = ExplicitVersions->new({
36 ordered_versions => $versions,
38 schema_version => '1.0',
39 database_version => '1.0',
42 ok $vh, 'VersionHandler gets instantiated';
45 !$vh->next_version_set,
46 'next version set returns undef if we are at the version requested'
51 my $vh = ExplicitVersions->new({
52 ordered_versions => $versions,
54 schema_version => '1.0',
55 database_version => '1.0',
58 ok $vh, 'VersionHandler gets instantiated';
60 eq_array($vh->next_version_set, [qw( 1.0 2.0 )]),
61 'first version pair works'
64 eq_array($vh->next_version_set, [qw( 2.0 3.0 )]),
65 'second version pair works'
68 eq_array($vh->next_version_set, [qw( 3.0 4.0 )]),
69 'third version pair works'
72 eq_array($vh->next_version_set, [qw( 4.0 5.0 )]),
73 'fourth version pair works'
75 ok( !$vh->next_version_set, 'no more versions after final pair' );
76 ok( !$vh->next_version_set, 'still no more versions after final pair' );
80 my $vh = ExplicitVersions->new({
81 ordered_versions => $versions,
83 schema_version => '5.0',
84 database_version => '5.0',
87 ok $vh, 'VersionHandler gets instantiated';
89 eq_array($vh->previous_version_set, [qw( 5.0 4.0 )]),
90 'first version pair works'
93 eq_array($vh->previous_version_set, [qw( 4.0 3.0 )]),
94 'second version pair works'
97 eq_array($vh->previous_version_set, [qw( 3.0 2.0 )]),
98 'third version pair works'
101 eq_array($vh->previous_version_set, [qw( 2.0 1.0 )]),
102 'fourth version pair works'
104 ok( !$vh->previous_version_set, 'no more versions after final pair' );
105 ok( !$vh->previous_version_set, 'still no more versions after final pair' );
109 my $vh = ExplicitVersions->new({
110 ordered_versions => $versions,
111 schema_version => '2.0',
112 database_version => '1.1',
114 $vh->next_version_set
115 } 'dies if database version not found in ordered_versions';
118 my $vh = ExplicitVersions->new({
119 ordered_versions => $versions,
121 schema_version => '1.0',
122 database_version => '1.0',
124 $vh->next_version_set;
125 } 'cannot request an upgrade before the current version';
128 my $vh = ExplicitVersions->new({
129 ordered_versions => $versions,
131 schema_version => '1.0',
132 database_version => '1.0',
134 $vh->previous_version_set;
135 } 'cannot request a downgrade after the current version';
138 #vim: ts=2 sw=2 expandtab