Another overhaul of transaction/savepoint handling
[dbsrgits/DBIx-Class-Historic.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;
3b80fa31 22
d0c7015c 23 my $death = $self->_dbi_connect_info->[3]{die};
24
014fd556 25 die "storage test died: $death" if $death eq 'before_populate';
d0c7015c 26 my $ret = $self->next::method (@_);
014fd556 27 die "storage test died: $death" if $death eq 'after_populate';
d0c7015c 28
29 return $ret;
30 }
31}
32
d0c7015c 33for (qw/before_populate after_populate/) {
3b80fa31 34 throws_ok (sub {
d0c7015c 35 my $schema = DBICTest::Schema->clone;
36 $schema->storage_type ('Dying::Storage');
37 $schema->connection (DBICTest->_database, { die => $_ });
38 $schema->storage->ensure_connected;
3b80fa31 39 }, qr/$_/, "$_ exception found");
d0c7015c 40}
41
d0c7015c 42done_testing;