File: 11-make_dsn.t

package info (click to toggle)
libtest-database-perl 1.112-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 272 kB
  • ctags: 83
  • sloc: perl: 637; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,030 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;
use Test::More;
use Test::Database::Driver;
use version;

# test version_matches() on a dummy driver

my @tests = (
    [ '', 'dbi:Dummy:' ],
    [ '', 'dbi:Dummy:bam=boff',             qw( bam boff ) ],
    [ '', 'dbi:Dummy:bam=boff;z_zwap=plop', qw( bam boff z_zwap plop ) ],
    [   'dbi:Dummy:bam=boff', 'dbi:Dummy:bam=boff;z_zwap=plop',
        qw( z_zwap plop )
    ],
    [   'dbi:Dummy:bam=boff',
        'dbi:Dummy:bam=boff;z_zwap=plop;zowie=sock',
        qw( z_zwap plop zowie sock )
    ],
);

@Test::Database::Driver::Dummy::ISA = qw( Test::Database::Driver );

plan tests => scalar @tests;

for my $t (@tests) {
    my ( $driver_dsn, $dsn, @args ) = @$t;
    my $driver = bless { driver_dsn => $driver_dsn },
        'Test::Database::Driver::Dummy';

    my $got = $driver->make_dsn(@args);
    is( $got, $dsn, $driver->driver_dsn() . ' ' . to_string(@args) );
}

sub to_string {
    my %args = @_;
    return
        '( ' . join( ', ', map {"$_ => $args{$_}"} sort keys %args ) . ' )';
}