Forgotten manifest adjust after a2bd379666
[dbsrgits/DBIx-Class.git] / t / cdbi / 98-failure.t
CommitLineData
5a66aa65 1use strict;
4a233f30 2use warnings;
5a66aa65 3use Test::More;
4
5#----------------------------------------------------------------------
6# Test database failures
7#----------------------------------------------------------------------
8
50891152 9use lib 't/cdbi/testlib';
5a66aa65 10use Film;
11
12Film->create_test_film;
13
14{
6a3bf251 15 my $btaste = Film->retrieve('Bad Taste');
16 isa_ok $btaste, 'Film', "We have Bad Taste";
17 {
18 no warnings 'redefine';
19 local *DBIx::ContextualFetch::st::execute = sub { die "Database died" };
20 eval { $btaste->delete };
21 ::like $@, qr/Database died/s, "We failed";
22 }
23 my $still = Film->retrieve('Bad Taste');
24 isa_ok $btaste, 'Film', "We still have Bad Taste";
5a66aa65 25}
26
27{
6a3bf251 28 my $btaste = Film->retrieve('Bad Taste');
29 isa_ok $btaste, 'Film', "We have Bad Taste";
30 $btaste->numexplodingsheep(10);
31 {
32 no warnings 'redefine';
33 local *DBIx::ContextualFetch::st::execute = sub { die "Database died" };
34 eval { $btaste->update };
35 ::like $@, qr/Database died/s, "We failed";
36 }
37 $btaste->discard_changes;
38 my $still = Film->retrieve('Bad Taste');
39 isa_ok $btaste, 'Film', "We still have Bad Taste";
40 is $btaste->numexplodingsheep, 1, "with 1 sheep";
5a66aa65 41}
42
43if (0) {
6a3bf251 44 my $sheep = Film->maximum_value_of('numexplodingsheep');
45 is $sheep, 1, "1 exploding sheep";
46 {
47 local *DBIx::ContextualFetch::st::execute = sub { die "Database died" };
48 my $sheep = eval { Film->maximum_value_of('numexplodingsheep') };
49 ::like $@, qr/select.*Database died/s,
50 "Handle database death in single value select";
51 }
5a66aa65 52}
53
d9bd5195 54done_testing;