Use 'h=localhost' if no DSN or DSN options given. Remove unused DSN parts (D and t) and don't copy some parts. Move issue_947.t tests into standard_options.t and remove issue_947.t.

This commit is contained in:
Daniel Nichter
2011-10-14 07:59:43 -06:00
parent 60d8b1a710
commit 48fb4baa7c
5 changed files with 143 additions and 83 deletions

View File

@@ -9,7 +9,7 @@ BEGIN {
use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More tests => 14;
use Test::More tests => 16;
use Sandbox;
use OptionParser;
@@ -36,6 +36,7 @@ $dp->prop('set-vars', $o->get('set-vars'));
sub make_cxn {
my (%args) = @_;
$o->get_opts();
return new Cxn(
OptionParser => $o,
DSNParser => $dp,
@@ -197,6 +198,50 @@ is_deeply(
"cxn->dsn()"
);
# ############################################################################
# Default cxn, should be equivalent to 'h=localhost'.
# ############################################################################
my $default_cxn = make_cxn();
is_deeply(
$default_cxn->dsn(),
{
h => 'localhost',
P => undef,
u => undef,
p => undef,
A => undef,
F => undef,
S => undef,
D => undef,
t => undef,
n => 'h=localhost',
},
"Defaults to h=localhost"
);
# But now test if it will inherit just a few standard connection options.
@ARGV = qw(--port 12345);
$default_cxn = make_cxn();
is_deeply(
$default_cxn->dsn(),
{
h => 'localhost',
P => '12345',
u => undef,
p => undef,
A => undef,
F => undef,
S => undef,
D => undef,
t => undef,
n => 'h=localhost,P=12345',
},
"Default cxn inherits default connection options"
);
@ARGV = ();
$o->get_opts();
# #############################################################################
# Done.
# #############################################################################