fix and regression test for RT #62642
[dbsrgits/DBIx-Class.git] / t / storage / exception.t
CommitLineData
d0c7015c 1use strict;
2use warnings;
3
4use Test::More;
5use Test::Exception;
6use lib qw(t/lib);
7use DBICTest;
8use DBICTest::Schema;
9
f66e15f3 10# make sure nothing eats the exceptions (an unchecked eval in Storage::DESTROY used to be a problem)
11
d0c7015c 12{
13 package Dying::Storage;
14
15 use warnings;
16 use strict;
17
18 use base 'DBIx::Class::Storage::DBI';
19
20 sub _populate_dbh {
21 my $self = shift;
22 my $death = $self->_dbi_connect_info->[3]{die};
23
014fd556 24 die "storage test died: $death" if $death eq 'before_populate';
d0c7015c 25 my $ret = $self->next::method (@_);
014fd556 26 die "storage test died: $death" if $death eq 'after_populate';
d0c7015c 27
28 return $ret;
29 }
30}
31
d0c7015c 32for (qw/before_populate after_populate/) {
014fd556 33 dies_ok (sub {
d0c7015c 34 my $schema = DBICTest::Schema->clone;
35 $schema->storage_type ('Dying::Storage');
36 $schema->connection (DBICTest->_database, { die => $_ });
37 $schema->storage->ensure_connected;
014fd556 38 }, "$_ exception found");
d0c7015c 39}
40
d0c7015c 41done_testing;