Index: t/33storage_reconnect.t =================================================================== --- t/33storage_reconnect.t (revision 3603) +++ t/33storage_reconnect.t (working copy) @@ -1,12 +1,17 @@ use strict; use warnings; +use FindBin; +use File::Copy; use Test::More; use lib qw(t/lib); use DBICTest; -plan tests => 2; +plan tests => 4; +my $db_orig = "$FindBin::Bin/var/DBIxClass.db"; +my $db_tmp = "$db_orig.tmp"; + # Set up the "usual" sqlite for DBICTest my $schema = DBICTest->init_schema; @@ -24,3 +29,21 @@ # 4. Success! my @art_two = $schema->resultset("Artist")->search({ }, { order_by => 'name DESC'}); cmp_ok(@art_two, '==', 3, "Three artists returned"); + +### Now, disconnect the dbh, and move the db file so it can't be reconnected +$schema->storage->_dbh->disconnect; +move( $db_orig, $db_tmp ); + +### Try the operation again... it should fail, since there's no db +eval { + my @art_three = $schema->resultset("Artist")->search( {}, { order_by => 'name DESC' } ); +}; +ok( $@, 'The operation failed' ); + +### Now, move the db file back to the correct name +move( $db_tmp, $db_orig ); + +### Try the operation again... this time, it should succeed +my @art_four = $schema->resultset("Artist")->search( {}, { order_by => 'name DESC' } ); +cmp_ok( @art_two, '==', 3, "Three artists returned" ); +