add test for connect_info hashref
[dbsrgits/DBIx-Class.git] / t / 32connect_hash.t
1 use strict;
2 use warnings;  
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7
8 plan tests => 1;
9
10 # Set up the "usual" sqlite for DBICTest
11 my $normal_schema = DBICTest->init_schema( sqlite_use_file => 1 );
12
13 my @connect_info = @{ $normal_schema->storage->_dbi_connect_info };
14
15 my %connect_info = (
16   dsn => $connect_info[0],
17   user => $connect_info[1],
18   password => $connect_info[2],
19   %{ $connect_info[3] },
20   AutoCommit => 1,
21   cursor_class => 'DBIx::Class::Storage::DBI::Cursor'
22 );
23
24 # Make sure we have no active connection
25 $normal_schema->storage->disconnect;
26
27 # Make a new clone with a new connection, using a hash reference
28 my $hash_schema = $normal_schema->connect(\%connect_info);
29
30 # Stolen from 60core.t - this just verifies things seem to work at all
31 my @art = $hash_schema->resultset("Artist")->search({ }, { order_by => 'name DESC'});
32 cmp_ok(@art, '==', 3, "Three artists returned");