fix VersionResult to actually work
[dbsrgits/DBIx-Class-DeploymentHandler.git] / t / 02-instantiation.t
1 #!perl
2
3 use Test::More;
4
5 use lib 't/lib';
6 use DBICTest;
7 use DBIx::Class::DeploymentHandler;
8
9 my $sql_dir = 't/sql';
10
11 VERSION1: {
12         use_ok 'DBICVersion_v1';
13         my $s = DBICVersion::Schema->connect('dbi:SQLite::memory:');
14         ok($s, 'DBICVersion::Schema 1.0 instantiates correctly');
15         my $handler = DBIx::Class::DeploymentHandler->new({
16                 schema => $s,
17         });
18
19         ok($handler, 'DBIx::Class::DeploymentHandler w/1.0 instantiates correctly');
20
21         my $version = $s->schema_version();
22         $handler->create_ddl_dir( 'SQLite', $version, $sql_dir, 0);
23         ok(-e 't/sql/DBICVersion-Schema-1.0-SQLite.sql', 'DDL for 1.0 got created successfully');
24 }
25
26 VERSION2: {
27         use_ok 'DBICVersion_v2';
28         my $s = DBICVersion::Schema->connect('dbi:SQLite::memory:');
29         ok($s, 'DBICVersion::Schema 2.0 instantiates correctly');
30         my $handler = DBIx::Class::DeploymentHandler->new({
31                 schema => $s,
32         });
33
34         ok($handler, 'DBIx::Class::DeploymentHandler w/2.0 instantiates correctly');
35
36         $version = $s->schema_version();
37         $handler->create_ddl_dir( 'SQLite', $version, $sql_dir, 0);
38         $handler->create_ddl_dir( 'SQLite', $version, $sql_dir, '1.0');
39         ok(-e 't/sql/DBICVersion-Schema-2.0-SQLite.sql', 'DDL for 2.0 got created successfully');
40         ok(-e 't/sql/DBICVersion-Schema-1.0-2.0-SQLite.sql', 'DDL for migration from 1.0 to 2.0 got created successfully');
41 }
42
43 VERSION3: {
44         use_ok 'DBICVersion_v3';
45         my $s = DBICVersion::Schema->connect('dbi:SQLite::memory:');
46         ok($s, 'DBICVersion::Schema 3.0 instantiates correctly');
47         my $handler = DBIx::Class::DeploymentHandler->new({
48                 schema => $s,
49         });
50
51         ok($handler, 'DBIx::Class::DeploymentHandler w/3.0 instantiates correctly');
52
53         $version = $s->schema_version();
54         $handler->create_ddl_dir( 'SQLite', $version, $sql_dir, 0);
55         $handler->create_ddl_dir( 'SQLite', $version, $sql_dir, '1.0');
56         $handler->create_ddl_dir( 'SQLite', $version, $sql_dir, '2.0');
57         ok(-e 't/sql/DBICVersion-Schema-3.0-SQLite.sql', 'DDL for 3.0 got created successfully');
58         ok(-e 't/sql/DBICVersion-Schema-1.0-3.0-SQLite.sql', 'DDL for migration from 1.0 to 3.0 got created successfully');
59         ok(-e 't/sql/DBICVersion-Schema-2.0-3.0-SQLite.sql', 'DDL for migration from 2.0 to 3.0 got created successfully');
60 }
61
62 done_testing;