DBIx-Config

 view release on metacpan or  search on metacpan

t/04_dbi_credentials.t  view on Meta::CPAN

            },
        get => 
            [
                'dbi:mysql:somedb',
                'username',
                'password',
                {},
            ],
        title => "Hashref connections work.",
    },
    {
        put => [ 'dbi:mysql:somedb', 'username', 'password' ],
        get => 
            [
                'dbi:mysql:somedb',
                'username',
                'password',
                {},
            ],
        title => "Array connections work.",
    },
    {
        put => [ 'DATABASE' ],
        get => [ 'DATABASE', undef, undef, {} ],
        title => "DSN gets the first element name.",
    },
    {
        put => [ 'dbi:mysql:somedb', 'username', 'password', { PrintError => 1 } ],
        get => 
        [
            'dbi:mysql:somedb',
            'username',
            'password',
            { PrintError  => 1 },

        ],
        title => "Normal option hashes pass through.",
    },
    {
        put => [ 'DATABASE', 'USERNAME', { hostname => 'hostname' } ],
        get => [ 'DATABASE', 'USERNAME', undef, { hostname => 'hostname' } ],
        title => "Ensure (string, string, hashref) format works correctly.",
    },
    {
        put => [ 'DATABASE', 'USERNAME', 'PASSWORD', { hostname => 'hostname' } ],
        get => [ 'DATABASE', 'USERNAME', 'PASSWORD', { hostname => 'hostname' } ],
        title => "Ensure (string, string, string, hashref) format works correctly.",
    },
    {
        put => [ 'DATABASE', 'U', 'P', { foo => "bar" }, { hostname => 'hostname' } ],
        get => [ 'DATABASE', 'U', 'P', { foo => "bar", hostname => 'hostname' } ],
        title => "Ensure (string, string, string, hashref, hashref) format works correctly.",
    },

];


for my $test ( @$tests ) {
    is_deeply( 
        [
            DBIx::Config->_dbi_credentials(
                DBIx::Config->_make_config( 
                    ref $test->{put} eq 'ARRAY' ? @{$test->{put}} : $test->{put}
                )
            ), 
        ],
        $test->{get}, 
        $test->{title} 
    );
}

done_testing;



( run in 2.399 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )