From: Dagfinn Ilmari Mannsåker Date: Tue, 10 Oct 2017 15:52:29 +0000 (+0100) Subject: Only run the col_accessor_map tests once per connect_info X-Git-Tag: 0.07048~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=20d44ba70154a47099b1c9d9ffa58af75d55c28c;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Only run the col_accessor_map tests once per connect_info This makes the tests count insensitive to the number of rescans. --- diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index e49e411..e3851f3 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -117,12 +117,9 @@ sub run_tests { my $extra_count = $self->{extra}{count} || 0; my $col_accessor_map_tests = 6; - my $num_rescans = 6; - $num_rescans++ if $self->{vendor} eq 'mssql'; - $num_rescans++ if $self->{vendor} eq 'Firebird'; plan tests => @connect_info * - (233 + $num_rescans * $col_accessor_map_tests + $extra_count + ($self->{data_type_tests}{test_count} || 0)); + (233 + $col_accessor_map_tests + $extra_count + ($self->{data_type_tests}{test_count} || 0)); foreach my $info_idx (0..$#connect_info) { my $info = $connect_info[$info_idx]; @@ -234,6 +231,8 @@ sub setup_schema { $self->{use_moose} = 1; } + $self->{col_accessor_map_tests_run} = 0; + my %loader_opts = ( constraint => $self->CONSTRAINT, result_namespace => RESULT_NAMESPACE, @@ -260,7 +259,7 @@ sub setup_schema { col_collision_map => { '^(can)\z' => 'caught_collision_%s' }, rel_collision_map => { '^(set_primary_key)\z' => 'caught_rel_collision_%s' }, relationship_attrs => { many_to_many => { order_by => 'me.id' } }, - col_accessor_map => \&test_col_accessor_map, + col_accessor_map => sub { $self->test_col_accessor_map(@_) }, result_components_map => { LoaderTest2X => 'TestComponentForMap', LoaderTest1 => '+TestComponentForMapFQN' }, uniq_to_primary => 1, %{ $self->{loader_options} || {} }, @@ -2450,13 +2449,14 @@ sub rescan_without_warnings { } sub test_col_accessor_map { - my ( $column_name, $default_name, $context, $default_map ) = @_; + my ( $self, $column_name, $default_name, $context, $default_map ) = @_; if( lc($column_name) eq 'crumb_crisp_coating' ) { - is( $default_name, 'crumb_crisp_coating', 'col_accessor_map was passed the default name' ); - ok( $context->{$_}, "col_accessor_map func was passed the $_" ) - for qw( table table_name table_class table_moniker schema_class ); - + unless ($self->{col_accessor_map_tests_run}++) { + is( $default_name, 'crumb_crisp_coating', 'col_accessor_map was passed the default name' ); + ok( $context->{$_}, "col_accessor_map func was passed the $_" ) + for qw( table table_name table_class table_moniker schema_class ); + } return 'trivet'; } else { return $default_map->({