From: Matt S Trout Date: Thu, 21 Jul 2005 14:04:11 +0000 (+0000) Subject: All tests successful, 15 subtests skipped. Files=8, Tests=189 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5a66aa65d09bd48eb710e6d3ffccfcf20f2e7bd9;p=dbsrgits%2FDBIx-Class-Historic.git All tests successful, 15 subtests skipped. Files=8, Tests=189 --- diff --git a/t/cdbi-t/19-set_sql.t b/t/cdbi-t/19-set_sql.t index bab8f51..2278cd4 100644 --- a/t/cdbi-t/19-set_sql.t +++ b/t/cdbi-t/19-set_sql.t @@ -62,6 +62,8 @@ Film->set_sql( is $pgs[1]->id, $f4->id, "and F4"; }; +SKIP: { + skip "DBIx::Class doesn't have has_a yet", 6; { Actor->has_a(film => "Film"); Film->set_sql( @@ -104,3 +106,4 @@ Film->set_sql( is $apg[1]->title, "B", "and B"; } +} # end SKIP block diff --git a/t/cdbi-t/98-failure.t b/t/cdbi-t/98-failure.t new file mode 100644 index 0000000..fe41b05 --- /dev/null +++ b/t/cdbi-t/98-failure.t @@ -0,0 +1,57 @@ +use strict; +use Test::More; + +#---------------------------------------------------------------------- +# Test database failures +#---------------------------------------------------------------------- + +BEGIN { + eval "use DBD::SQLite"; + plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 7); +} + +use lib 't/testlib'; +use Film; + +Film->create_test_film; + +{ + my $btaste = Film->retrieve('Bad Taste'); + isa_ok $btaste, 'Film', "We have Bad Taste"; + { + no warnings 'redefine'; + local *DBIx::ContextualFetch::st::execute = sub { die "Database died" }; + eval { $btaste->delete }; + ::like $@, qr/Database died/s, "We failed"; + } + my $still = Film->retrieve('Bad Taste'); + isa_ok $btaste, 'Film', "We still have Bad Taste"; +} + +{ + my $btaste = Film->retrieve('Bad Taste'); + isa_ok $btaste, 'Film', "We have Bad Taste"; + $btaste->numexplodingsheep(10); + { + no warnings 'redefine'; + local *DBIx::ContextualFetch::st::execute = sub { die "Database died" }; + eval { $btaste->update }; + ::like $@, qr/Database died/s, "We failed"; + } + $btaste->discard_changes; + my $still = Film->retrieve('Bad Taste'); + isa_ok $btaste, 'Film', "We still have Bad Taste"; + is $btaste->numexplodingsheep, 1, "with 1 sheep"; +} + +if (0) { + my $sheep = Film->maximum_value_of('numexplodingsheep'); + is $sheep, 1, "1 exploding sheep"; + { + local *DBIx::ContextualFetch::st::execute = sub { die "Database died" }; + my $sheep = eval { Film->maximum_value_of('numexplodingsheep') }; + ::like $@, qr/select.*Database died/s, + "Handle database death in single value select"; + } +} +