Fix fix reference cycle in test col_accessor_map callback
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / lib / dbixcsl_common_tests.pm
index e3851f3..bff0999 100644 (file)
@@ -10,6 +10,7 @@ use Test::Differences;
 use DBIx::Class::Schema::Loader;
 use Class::Unload;
 use File::Path 'rmtree';
+use curry;
 use DBI;
 use File::Find 'find';
 use Class::Unload ();
@@ -181,12 +182,12 @@ sub run_only_extra_tests {
 
         $self->test_data_types($conn);
         $self->{extra}{run}->($conn, $monikers, $classes, $self) if $self->{extra}{run};
+        $conn->storage->disconnect;
 
         if (not ($ENV{SCHEMA_LOADER_TESTS_NOCLEANUP} && $info_idx == $#$connect_info)) {
             $self->drop_extra_tables_only;
             rmtree DUMP_DIR;
         }
-        $conn->storage->disconnect;
     }
 }
 
@@ -259,7 +260,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        => sub { $self->test_col_accessor_map(@_) },
+        col_accessor_map        => $self->curry::weak::test_col_accessor_map,
         result_components_map   => { LoaderTest2X => 'TestComponentForMap', LoaderTest1 => '+TestComponentForMapFQN' },
         uniq_to_primary         => 1,
         %{ $self->{loader_options} || {} },
@@ -1389,9 +1390,9 @@ TODO: {
     diag $@ if $@ && (not $TODO);
 }
 
-    $self->drop_tables unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP};
-
     $conn->storage->disconnect;
+
+    $self->drop_tables unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP};
 }
 
 sub test_data_types {