X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fstorage%2Fdbi_env.t;h=462da111f0e3e050c7cfcd4fdacb82f0cf5edc93;hb=b0c42bbc89cfad32585c32d5360cc1151b2ad8c9;hp=a22b91c7e75e5d4160bf5a4acf7f1db6661365ba;hpb=f54428abf9cc7d7e5604745335694eaf558f6820;p=dbsrgits%2FDBIx-Class.git diff --git a/t/storage/dbi_env.t b/t/storage/dbi_env.t index a22b91c..462da11 100644 --- a/t/storage/dbi_env.t +++ b/t/storage/dbi_env.t @@ -4,17 +4,30 @@ 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; } @@ -86,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;