X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F86might_have.t;h=c1a66dee5b2c9a69dc8eb4a83b363a16259a5ca8;hb=8273e845426f0187b4ad6c4a1b42286fa09a648f;hp=81cbf84bc8bec35b78e6b0577f83a52f6fab0907;hpb=a47e123334d8bcea0d34dc9ea09738d6f3b1fd49;p=dbsrgits%2FDBIx-Class.git diff --git a/t/86might_have.t b/t/86might_have.t index 81cbf84..c1a66de 100644 --- a/t/86might_have.t +++ b/t/86might_have.t @@ -1,20 +1,16 @@ use strict; -use warnings; +use warnings; use Test::More; +use Test::Warn; use lib qw(t/lib); use DBICTest; my $schema = DBICTest->init_schema(); my $queries; -#$schema->storage->debugfh(IO::File->new('t/var/temp.trace', 'w')); $schema->storage->debugcb( sub{ $queries++ } ); - -eval "use DBD::SQLite"; -plan skip_all => 'needs DBD::SQLite for testing' if $@; -plan tests => 2; - +my $sdebug = $schema->storage->debug; my $cd = $schema->resultset("CD")->find(1); $cd->title('test'); @@ -25,10 +21,10 @@ $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(0); +$schema->storage->debug($sdebug); my $cd2 = $schema->resultset("CD")->find(2, {prefetch => 'liner_notes'}); @@ -40,8 +36,29 @@ $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'); -$schema->storage->debug(0); - +warning_like { + 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();