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