X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fstorage%2Fdbi_env.t;h=462da111f0e3e050c7cfcd4fdacb82f0cf5edc93;hb=6853e2c32de07a3cec73855597ccc8b863cd4d54;hp=5ef4274aa3f5223c4fe27f8d4e1865d551987ef1;hpb=442cb03d3bcf54768c832e20b0c6106542002820;p=dbsrgits%2FDBIx-Class.git diff --git a/t/storage/dbi_env.t b/t/storage/dbi_env.t index 5ef4274..462da11 100644 --- a/t/storage/dbi_env.t +++ b/t/storage/dbi_env.t @@ -1,21 +1,33 @@ -#!/usr/bin/perl use strict; use warnings; use lib qw(t/lib); use DBICTest; use Test::More; use Test::Exception; +use DBIx::Class::_Util 'sigwarn_silencer'; BEGIN { delete @ENV{qw(DBI_DSN DBI_DRIVER)} } -my $schema; +$ENV{DBICTEST_LOCK_HOLDER} = -1; -DBICTest->init_schema(sqlite_use_file => 1); +# pre-populate +my $schema = DBICTest->init_schema(sqlite_use_file => 1); my $dbname = DBICTest->_sqlite_dbname(sqlite_use_file => 1); sub count_sheep { my $schema = shift; + + local $SIG{__WARN__} = sigwarn_silencer( + qr/ + \QThis version of DBIC does not yet seem to supply a driver for your particular RDBMS\E + | + \QUnable to extract a driver name from connect info\E + | + \QYour storage class (DBIx::Class::Storage::DBI) does not set sql_limit_dialect\E + /x + ); + scalar $schema->resultset('Artist')->search( { name => "Exploding Sheep" } ) ->all; } @@ -87,4 +99,21 @@ $schema = DBICTest::Schema->connect; lives_ok { count_sheep($schema) } 'SQLite in DBI_DRIVER (not DBI_DSN)'; isa_ok $schema->storage, 'DBIx::Class::Storage::DBI::SQLite'; +# make sure that dynamically setting DBI_DSN post-connect works +{ + local $ENV{DBI_DSN}; + + my $s = DBICTest::Schema->connect(); + + throws_ok { + $s->storage->ensure_connected + } qr/You did not provide any connection_info/, + 'sensible exception on empty conninfo connect'; + + $ENV{DBI_DSN} = 'dbi:SQLite::memory:'; + + lives_ok { $s->storage->ensure_connected } 'Second connection attempt worked'; + isa_ok ( $s->storage, 'DBIx::Class::Storage::DBI::SQLite' ); +} + done_testing;