Commit | Line | Data |
24794769 |
1 | #!perl |
2 | |
3 | use Test::More; |
4 | use Test::Exception; |
5 | |
6 | use lib 't/lib'; |
02d58ac0 |
7 | use DBICDHTest; |
24794769 |
8 | use DBICTest; |
9 | use DBIx::Class::DeploymentHandler; |
c703d15d |
10 | use DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions; |
24794769 |
11 | my $db = 'dbi:SQLite:db.db'; |
12 | my @connection = ($db, '', '', { ignore_version => 1 }); |
13 | my $sql_dir = 't/sql'; |
14 | |
02d58ac0 |
15 | DBICDHTest::ready; |
24794769 |
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 | }); |
fb105cfa |
26 | my $v_storage = $handler->version_storage; |
24794769 |
27 | my $version = $s->schema_version(); |
a912450b |
28 | $handler->prepare_install(); |
24794769 |
29 | |
30 | $handler->install; |
31 | { |
c703d15d |
32 | my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({ |
24794769 |
33 | schema => $s, |
34 | ordered_versions => $versions, |
35 | to_version => '5.0', |
fb105cfa |
36 | version_storage => $v_storage, |
24794769 |
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 | { |
c703d15d |
46 | my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({ |
24794769 |
47 | schema => $s, |
48 | ordered_versions => $versions, |
fb105cfa |
49 | version_storage => $v_storage, |
24794769 |
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 | { |
c703d15d |
57 | my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({ |
24794769 |
58 | schema => $s, |
59 | ordered_versions => $versions, |
fb105cfa |
60 | version_storage => $v_storage, |
24794769 |
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 | |
c703d15d |
70 | my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({ |
24794769 |
71 | schema => $s, |
72 | ordered_versions => $versions, |
fb105cfa |
73 | version_storage => $v_storage, |
24794769 |
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 |