From: Peter Rabbitson Date: Fri, 12 Feb 2016 08:27:38 +0000 (+0100) Subject: Better testing that RT#63874 being fully fixed by ddcc02d1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d0289ee13bb30b44fbdc541cc796174c40929bc4;p=dbsrgits%2FDBIx-Class-Historic.git Better testing that RT#63874 being fully fixed by ddcc02d1 Also separate some of the basic find() tests to a new testfile --- diff --git a/Changes b/Changes index 9546752..ba1c4aa 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,7 @@ Revision history for DBIx::Class insulated from changes in control flow, as the handlers are only invoked when an error is leaving the DBIC internals to be handled by the caller (n.b. https://github.com/PerlDancer/Dancer2/issues/1125) + (also fixes the previously rejected RT#63874) - $result->related_resultset() no longer passes extra arguments to an underlying search_rs(), as by design these arguments would be used only on the first call to ->related_resultset(), and ignored diff --git a/t/60core.t b/t/60core.t index d01a5fd..0420a9f 100644 --- a/t/60core.t +++ b/t/60core.t @@ -125,19 +125,8 @@ warnings_exist { $schema->resultset('Artist')->search_rs(id => 4) } qr/\Qsearch( %condition ) is deprecated/, 'Deprecation warning on ->search( %condition )'; -# this has been warning for 4 years, killing -throws_ok { - $schema->resultset('Artist')->find(artistid => 4); -} qr|expects either a column/value hashref, or a list of values corresponding to the columns of the specified unique constraint|; - is($schema->resultset("Artist")->count, 4, 'count ok'); -# test find on an unresolvable condition -is( - $schema->resultset('Artist')->find({ artistid => [ -and => 1, 2 ]}), - undef -); - # test find_or_new { diff --git a/t/resultset/find.t b/t/resultset/find.t new file mode 100644 index 0000000..8244a6d --- /dev/null +++ b/t/resultset/find.t @@ -0,0 +1,47 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + +use strict; +use warnings; + +use Test::More; +use Test::Exception; + +use DBICTest; + +my $schema = DBICTest->init_schema(); + +# this has been warning for 4 years, killing +throws_ok { + $schema->resultset('Artist')->find(artistid => 4); +} qr|expects either a column/value hashref, or a list of values corresponding to the columns of the specified unique constraint|; + +{ + my $exception_callback_count = 0; + + my $ea = $schema->exception_action(sub { + $exception_callback_count++; + die @_; + }); + + # No, this is not a great idea. + # Yes, people do it anyway. + # Might as well test that we have fixed it for good, by never invoking + # a potential __DIE__ handler in internal_try() stacks + local $SIG{__DIE__} = sub { $ea->(@_) }; + + # test find on non-unique non-existing value + is ( + $schema->resultset('Artist')->find({ rank => 666 }), + undef + ); + + # test find on an unresolvable condition + is( + $schema->resultset('Artist')->find({ artistid => [ -and => 1, 2 ]}), + undef + ); + + is $exception_callback_count, 0, 'exception_callback never invoked'; +} + +done_testing;