Test suite now is fully parallelizable
[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 File::Temp 'tempdir';
14 use Test::Exception;
15
16 my $db = 'dbi:SQLite::memory:';
17 my @connection = ($db, '', '', { ignore_version => 1, on_connect_do => sub { die }});
18 my $sql_dir = tempdir( CLEANUP => 1 );
19
20 VERSION1: {
21   use_ok 'DBICVersion_v1';
22   my $s = DBICVersion::Schema->connect(@connection);
23   $DBICVersion::Schema::VERSION = 1;
24   ok($s, 'DBICVersion::Schema 1 instantiates correctly');
25   ok !$s->storage->connected, 'creating schema did not connect';
26   my $handler = DH->new({
27     script_directory => $sql_dir,
28     schema => $s,
29     databases => 'SQLite',
30     sql_translator_args => { add_drop_table => 0 },
31   });
32   ok !$s->storage->connected, 'creating handler did not connect';
33   ok($handler, 'DBIx::Class::DeploymentHandler w/1 instantiates correctly');
34
35   mkpath("$sql_dir/SQLite/initialize/1");
36   $handler->initialize({ version => 1, storage_type => 'SQLite' });
37   ok !$s->storage->connected, 'creating schema did not connect';
38 }
39 done_testing;