From: Peter Rabbitson Date: Mon, 17 Nov 2008 02:48:57 +0000 (+0000) Subject: Silence cdbi tests like everything else X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dec1bfe02a3edde0ad981a663811926f29825777;p=dbsrgits%2FDBIx-Class-Historic.git Silence cdbi tests like everything else --- diff --git a/lib/DBIx/Class/ResultSourceProxy/Table.pm b/lib/DBIx/Class/ResultSourceProxy/Table.pm index 61b53fa..a1abb1b 100644 --- a/lib/DBIx/Class/ResultSourceProxy/Table.pm +++ b/lib/DBIx/Class/ResultSourceProxy/Table.pm @@ -40,7 +40,7 @@ sub _init_result_source_instance { $class->result_source_instance($table); - if ($class->can('schema_instance')) { + if ($class->can('schema_instance') && $class->schema_instance) { $class =~ m/([^:]+)$/; $class->schema_instance->register_class($class, $class); } diff --git a/t/cdbi-t/02-Film.t b/t/cdbi-t/02-Film.t index ee28a68..bd42d6e 100644 --- a/t/cdbi-t/02-Film.t +++ b/t/cdbi-t/02-Film.t @@ -231,16 +231,25 @@ ok( ); # Test that a disconnect doesnt harm anything. -Film->db_Main->disconnect; -@films = Film->search({ Rating => 'NC-17' }); -ok(@films == 1 && $films[0]->id eq $gone->id, 'auto reconnection'); - -# Test discard_changes(). -my $orig_director = $btaste->Director; -$btaste->Director('Lenny Bruce'); -is($btaste->Director, 'Lenny Bruce', 'set new Director'); -$btaste->discard_changes; -is($btaste->Director, $orig_director, 'discard_changes()'); +{ + # SQLite is loud on disconnect/reconnect. + # This is solved in DBIC but not in ContextualFetch + local $SIG{__WARN__} = sub { + warn @_ unless $_[0] =~ + /active statement handles|inactive database handle/; + }; + + Film->db_Main->disconnect; + @films = Film->search({ Rating => 'NC-17' }); + ok(@films == 1 && $films[0]->id eq $gone->id, 'auto reconnection'); + + # Test discard_changes(). + my $orig_director = $btaste->Director; + $btaste->Director('Lenny Bruce'); + is($btaste->Director, 'Lenny Bruce', 'set new Director'); + $btaste->discard_changes; + is($btaste->Director, $orig_director, 'discard_changes()'); +} SKIP: { skip "ActiveState perl produces additional warnings", 3 diff --git a/t/cdbi-t/15-accessor.t b/t/cdbi-t/15-accessor.t index 1f7a985..91d6145 100644 --- a/t/cdbi-t/15-accessor.t +++ b/t/cdbi-t/15-accessor.t @@ -114,6 +114,9 @@ eval { like $@, qr/film/, "no hasa film"; eval { + local $SIG{__WARN__} = sub { + warn @_ unless $_[0] =~ /Query returned more than one row/; + }; ok my $f = $ac->movie, "hasa movie"; isa_ok $f, "Film"; is $f->id, $bt->id, " - Bad Taste"; diff --git a/t/cdbi-t/23-cascade.t b/t/cdbi-t/23-cascade.t index 50a1647..af8689b 100644 --- a/t/cdbi-t/23-cascade.t +++ b/t/cdbi-t/23-cascade.t @@ -1,5 +1,6 @@ use strict; use Test::More; +use Data::Dumper; BEGIN { eval "use DBIx::Class::CDBICompat;"; @@ -48,7 +49,8 @@ for my $args ({ no_cascade_delete => 1 }, { cascade => "None" }) { is $dir->nasties, 1, "We have one nasty"; ok $dir->delete; - ok +Film->retrieve("Alligator"), "has_many with @{[ keys %$args ]} => @{[ values %$args ]}"; + local $Data::Dumper::Terse = 1; + ok +Film->retrieve("Alligator"), 'has_many with ' . Dumper ($args);; $kk->delete; } diff --git a/t/testlib/MyBase.pm b/t/testlib/MyBase.pm index 7951482..eeb7cf0 100644 --- a/t/testlib/MyBase.pm +++ b/t/testlib/MyBase.pm @@ -8,7 +8,8 @@ use DBI; use vars qw/$dbh/; -my @connect = ("dbi:mysql:test", "", ""); +# temporary, might get switched to the new test framework someday +my @connect = ("dbi:mysql:test", "", "", { PrintError => 0}); $dbh = DBI->connect(@connect) or die DBI->errstr; my @table;