From: Rafael Kitover Date: Sun, 24 May 2009 23:53:12 +0000 (+0000) Subject: added test to make sure only one connection to ODBC/MSSQL is made X-Git-Tag: v0.08103~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8c0104fe43324a5e29d798a93bdb634bac61f3fb;p=dbsrgits%2FDBIx-Class.git added test to make sure only one connection to ODBC/MSSQL is made --- diff --git a/t/746mssql.t b/t/746mssql.t index 05317b6..f53d49f 100644 --- a/t/746mssql.t +++ b/t/746mssql.t @@ -10,11 +10,20 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PA plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); -plan tests => 12; +plan tests => 13; my $schema = DBICTest::Schema->connect($dsn, $user, $pass, {AutoCommit => 1}); -$schema->storage->ensure_connected; +{ + no warnings 'redefine'; + my $connect_count = 0; + my $orig_connect = \&DBI::connect; + local *DBI::connect = sub { $connect_count++; goto &$orig_connect }; + + $schema->storage->ensure_connected; + + is( $connect_count, 1, 'only one connection made'); +} isa_ok( $schema->storage, 'DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server' );