X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F94versioning.t;h=af46ef768439fc8317d162983fe8e1cf0efbc467;hb=652d9b762d7b6d36c7dcc396e2cee5264c6d0a95;hp=ab9d2613e7acb37dd59f24f05c30fbb26f59468a;hpb=e48635f7178f8527ec3cc230f1cf869e8876dc39;p=dbsrgits%2FDBIx-Class.git diff --git a/t/94versioning.t b/t/94versioning.t index ab9d261..af46ef7 100644 --- a/t/94versioning.t +++ b/t/94versioning.t @@ -24,6 +24,11 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}; # in case it came from the env $ENV{DBIC_NO_VERSION_CHECK} = 0; +# FIXME - work around RT#113965 in combination with -T on older perls: +# the non-deparsing XS portion of D::D gets confused by some of the IO +# handles trapped in the debug object of DBIC. What a mess. +$Data::Dumper::Deparse = 1; + use_ok('DBICVersion_v1'); my $version_table_name = 'dbix_class_schema_versions'; @@ -281,6 +286,35 @@ is ), 3, "Expected number of connections at end of script" ; +# Test custom HandleError setting on an in-memory instance +{ + my $custom_handler = sub { die $_[0] }; + + # try to setup a custom error handle without unsafe set -- should + # fail, same behavior as regular Schema + throws_ok { + DBICVersion::Schema->connect( 'dbi:SQLite::memory:', undef, undef, { + HandleError => $custom_handler, + ignore_version => 1, + })->deploy; + } + qr/Refusing clobbering of \{HandleError\} installed on externally supplied DBI handle/, + 'HandleError with unsafe not set causes an exception' + ; + + # now try it with unsafe set -- should work (see RT #113741) + my $s = DBICVersion::Schema->connect( 'dbi:SQLite::memory:', undef, undef, { + unsafe => 1, + HandleError => $custom_handler, + ignore_version => 1, + }); + + $s->deploy; + + is $s->storage->dbh->{HandleError}, $custom_handler, 'Handler properly set on main schema'; + is $s->{vschema}->storage->dbh->{HandleError}, $custom_handler, 'Handler properly set on version subschema'; +} + END { rm_rf $ddl_dir unless $ENV{DBICTEST_KEEP_VERSIONING_DDL}; }