8 'DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions';
10 my $versions = [map "$_.0", 0..100];
13 my $vh = ExplicitVersions->new({
14 ordered_versions => $versions,
15 schema_version => '2.0',
16 database_version => '1.0',
19 ok $vh, 'VersionHandler gets instantiated';
22 eq_array($vh->next_version_set, [qw( 1.0 2.0 )]),
23 'first version pair works'
26 !$vh->next_version_set,
27 'next version set returns undef when we are done'
32 my $vh = ExplicitVersions->new({
33 ordered_versions => $versions,
35 schema_version => '1.0',
36 database_version => '1.0',
39 ok $vh, 'VersionHandler gets instantiated';
42 !$vh->next_version_set,
43 'next version set returns undef if we are at the version requested'
48 my $vh = ExplicitVersions->new({
49 ordered_versions => $versions,
51 schema_version => '1.0',
52 database_version => '1.0',
55 ok $vh, 'VersionHandler gets instantiated';
57 eq_array($vh->next_version_set, [qw( 1.0 2.0 )]),
58 'first version pair works'
61 eq_array($vh->next_version_set, [qw( 2.0 3.0 )]),
62 'second version pair works'
65 eq_array($vh->next_version_set, [qw( 3.0 4.0 )]),
66 'third version pair works'
69 eq_array($vh->next_version_set, [qw( 4.0 5.0 )]),
70 'fourth version pair works'
72 ok( !$vh->next_version_set, 'no more versions after final pair' );
73 ok( !$vh->next_version_set, 'still no more versions after final pair' );
77 my $vh = ExplicitVersions->new({
78 ordered_versions => $versions,
80 schema_version => '5.0',
81 database_version => '5.0',
84 ok $vh, 'VersionHandler gets instantiated';
86 eq_array($vh->previous_version_set, [qw( 4.0 5.0 )]),
87 'first version pair works'
90 eq_array($vh->previous_version_set, [qw( 3.0 4.0 )]),
91 'second version pair works'
94 eq_array($vh->previous_version_set, [qw( 2.0 3.0 )]),
95 'third version pair works'
98 eq_array($vh->previous_version_set, [qw( 1.0 2.0 )]),
99 'fourth version pair works'
101 ok( !$vh->previous_version_set, 'no more versions after final pair' );
102 ok( !$vh->previous_version_set, 'still no more versions after final pair' );
106 my $vh = ExplicitVersions->new({
107 ordered_versions => $versions,
108 schema_version => '2.0',
109 database_version => '1.1',
111 $vh->next_version_set
112 } 'dies if database version not found in ordered_versions';
115 my $vh = ExplicitVersions->new({
116 ordered_versions => $versions,
118 schema_version => '1.0',
119 database_version => '1.0',
121 $vh->next_version_set;
122 } 'cannot request an upgrade before the current version';
125 my $vh = ExplicitVersions->new({
126 ordered_versions => $versions,
128 schema_version => '1.0',
129 database_version => '1.0',
131 $vh->previous_version_set;
132 } 'cannot request a downgrade after the current version';
135 #vim: ts=2 sw=2 expandtab