X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F86might_have.t;h=0ca9a06f109d7cfead1c7e1a97cae45055d80564;hb=fa19e5d684ce8181f2fa2e0cd79bed14de889650;hp=8ebf7b8880e4630db4fa69d5056674e5c664bba7;hpb=a2287768f5c3dd665c469d7f9dfe99d369ff6781;p=dbsrgits%2FDBIx-Class.git diff --git a/t/86might_have.t b/t/86might_have.t index 8ebf7b8..0ca9a06 100644 --- a/t/86might_have.t +++ b/t/86might_have.t @@ -1,7 +1,8 @@ use strict; -use warnings; +use warnings; use Test::More; +use Test::Warn; use lib qw(t/lib); use DBICTest; @@ -11,8 +12,6 @@ my $queries; $schema->storage->debugcb( sub{ $queries++ } ); my $sdebug = $schema->storage->debug; -plan tests => 2; - my $cd = $schema->resultset("CD")->find(1); $cd->title('test'); @@ -22,7 +21,7 @@ $schema->storage->debug(1); $cd->update; -is($queries, 1, 'liner_notes (might_have) not prefetched - do not load +is($queries, 1, 'liner_notes (might_have) not prefetched - do not load liner_notes on update'); $schema->storage->debug($sdebug); @@ -37,7 +36,31 @@ $schema->storage->debug(1); $cd2->update; -is($queries, 1, 'liner_notes (might_have) prefetched - do not load +is($queries, 1, 'liner_notes (might_have) prefetched - do not load liner_notes on update'); +warning_like { + local $ENV{DBIC_DONT_VALIDATE_RELS}; + + DBICTest::Schema::Bookmark->might_have( + linky => 'DBICTest::Schema::Link', + { "foreign.id" => "self.link" }, + ); +} + qr{"might_have/has_one" must not be on columns with is_nullable set to true}, + 'might_have should warn if the self.id column is nullable'; + +{ + local $ENV{DBIC_DONT_VALIDATE_RELS} = 1; + warning_is { + DBICTest::Schema::Bookmark->might_have( + slinky => 'DBICTest::Schema::Link', + { "foreign.id" => "self.link" }, + ); + } + undef, + 'Setting DBIC_DONT_VALIDATE_RELS suppresses nullable relation warnings'; +} + $schema->storage->debug($sdebug); +done_testing();