rename upgrade_directory attr to script_directory
[dbsrgits/DBIx-Class-DeploymentHandler.git] / t / 04-preconnect.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use lib 't/lib';
7 use DBICDHTest;
8 use DBIx::Class::DeploymentHandler;
9 use aliased 'DBIx::Class::DeploymentHandler', 'DH';
10
11 use File::Path qw(remove_tree mkpath);
12 use Test::More;
13 use Test::Exception;
14
15 DBICDHTest::ready;
16
17 my $db = 'dbi:SQLite:db.db';
18 my @connection = ($db, '', '', { ignore_version => 1, }, { on_connect_do => sub { die }});
19 my $sql_dir = 't/sql';
20
21 VERSION1: {
22   use_ok 'DBICVersion_v1';
23   my $s = DBICVersion::Schema->connect(@connection);
24   $DBICVersion::Schema::VERSION = 1;
25   ok($s, 'DBICVersion::Schema 1 instantiates correctly');
26   ok !$s->storage->connected, 'creating schema did not connect';
27   my $handler = DH->new({
28     script_directory => $sql_dir,
29     schema => $s,
30     databases => 'SQLite',
31     sql_translator_args => { add_drop_table => 0 },
32   });
33   ok !$s->storage->connected, 'creating handler did not connect';
34   ok($handler, 'DBIx::Class::DeploymentHandler w/1 instantiates correctly');
35
36   mkpath('t/sql/SQLite/preinstall/1');
37   $handler->preinstall({ version => 1, storage_type => 'SQLite' });
38   ok !$s->storage->connected, 'creating schema did not connect';
39 }
40 done_testing;