Release 0.08110
[dbsrgits/DBIx-Class.git] / t / storage / exception.t
CommitLineData
d0c7015c 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
7use Test::Exception;
8use lib qw(t/lib);
9use DBICTest;
10use DBICTest::Schema;
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
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
32TODO: {
33local $TODO = "I have no idea what is going on here... but it ain't right";
34
35for (qw/before_populate after_populate/) {
36
014fd556 37 dies_ok (sub {
d0c7015c 38 my $schema = DBICTest::Schema->clone;
39 $schema->storage_type ('Dying::Storage');
40 $schema->connection (DBICTest->_database, { die => $_ });
41 $schema->storage->ensure_connected;
014fd556 42 }, "$_ exception found");
d0c7015c 43}
44
45}
46
47done_testing;
48
49__END__
50For reference - next::method goes to ::Storage::DBI::_populate_dbh
51which is:
52
53sub _populate_dbh {
54 my ($self) = @_;
55
56 my @info = @{$self->_dbi_connect_info || []};
57 $self->_dbh(undef); # in case ->connected failed we might get sent here
58 $self->_dbh($self->_connect(@info));
59
60 $self->_conn_pid($$);
61 $self->_conn_tid(threads->tid) if $INC{'threads.pm'};
62
63 $self->_determine_driver;
64
65 # Always set the transaction depth on connect, since
66 # there is no transaction in progress by definition
67 $self->{transaction_depth} = $self->_dbh_autocommit ? 0 : 1;
68
69 $self->_run_connection_actions unless $self->{_in_determine_driver};
70}
71
72After further tracing it seems that if I die() before $self->_conn_pid($$)
73the exception is propagated. If I die after it - it's lost. What The Fuck?!