1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
#!/usr/bin/perl
use warnings;
use strict;
use Test::More;
use DBIx::Class::Schema::Config;
my $tests = [
{
put =>
{
dsn => 'dbi:mysql:somedb',
user => 'username',
password => 'password',
},
get =>
{
dsn => 'dbi:mysql:somedb',
user => 'username',
password => 'password',
},
title => "Hashref connections work.",
},
{
put => [ 'dbi:mysql:somedb', 'username', 'password' ],
get =>
{
dsn => 'dbi:mysql:somedb',
user => 'username',
password => 'password',
},
title => "Array connections work.",
},
{
put => [ 'DATABASE' ],
get => { dsn => 'DATABASE', user => undef, password => undef },
title => "DSN gets the first element name.",
},
{
put => [ 'dbi:mysql:somedb', 'username', 'password', { PrintError => 1 } ],
get =>
{
dsn => 'dbi:mysql:somedb',
user => 'username',
password => 'password',
PrintError => 1,
},
title => "Normal option hashes pass through.",
},
{
put => [ 'DATABASE', 'USERNAME', { hostname => 'hostname' } ],
get => { dsn => 'DATABASE', user => 'USERNAME', hostname => 'hostname' },
title => "Ensure (string, string, hashref) format works correctly.",
},
{
put => [ 'DATABASE', 'USERNAME', 'PASSWORD', { hostname => 'hostname' } ],
get => { dsn => 'DATABASE', user => 'USERNAME', password => 'PASSWORD', hostname => 'hostname' },
title => "Ensure (string, string, string, hashref) format works correctly.",
},
{
put => [ 'DATABASE', 'U', 'P', { foo => "bar" }, { hostname => 'hostname' } ],
get => { dsn => 'DATABASE', user => 'U', password => 'P', foo => "bar", hostname => 'hostname' },
title => "Ensure (string, string, string, hashref, hashref) format works correctly.",
},
];
for my $test ( @$tests ) {
is_deeply(
DBIx::Class::Schema::Config->_make_connect_attrs(
ref $test->{put} eq 'ARRAY' ? @{$test->{put}} : $test->{put}
), $test->{get}, $test->{title} );
}
done_testing;
|