X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2Fdbixcsl_common_tests.pm;h=97de888c66b93d12d6756b5a1b756c85de65c31d;hb=3a89a69f4383e520ddbf4cb2ea22b2e044f7cd96;hp=059979d45b27474eba1b39807e870099cbe78479;hpb=2d945eb32f50afe6b1ab2fb796048db3c691ea79;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index 059979d..97de888 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -10,6 +10,7 @@ use File::Path; use DBI; use Digest::MD5; use File::Find 'find'; +use Class::Unload (); my $DUMP_DIR = './t/_common_dump'; rmtree $DUMP_DIR; @@ -85,20 +86,32 @@ sub _custom_column_info { sub run_tests { my $self = shift; - plan tests => 159 + ($self->{extra}->{count} || 0); + my @connect_info; - $self->create(); + if ($self->{dsn}) { + push @connect_info, [ @{$self}{qw/dsn user password connect_info_opts/ } ]; + } + else { + foreach my $info (@{ $self->{connect_info} || [] }) { + push @connect_info, [ @{$info}{qw/dsn user password connect_info_opts/ } ]; + } + } - my @connect_info = ( - $self->{dsn}, - $self->{user}, - $self->{password}, - $self->{connect_info_opts}, - ); + plan tests => @connect_info * (159 + ($self->{extra}->{count} || 0)); + + foreach my $info_idx (0..$#connect_info) { + my $info = $connect_info[$info_idx]; - # First, with in-memory classes - my $schema_class = $self->setup_schema(@connect_info); - $self->test_schema($schema_class); + @{$self}{qw/dsn user password connect_info_opts/} = @$info; + + $self->create(); + + my $schema_class = $self->setup_schema(@$info); + $self->test_schema($schema_class); + + rmtree $DUMP_DIR + unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP} && $info_idx == $#connect_info; + } } # defined in sub create @@ -137,6 +150,8 @@ sub setup_schema { $loader_opts{db_schema} = $self->{db_schema} if $self->{db_schema}; + Class::Unload->unload($schema_class); + my $file_count; my $expected_count = 36; { @@ -824,6 +839,8 @@ sub test_schema { $self->{extra}->{run}->($conn, $monikers, $classes) if $self->{extra}->{run}; + $self->drop_tables unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}; + $conn->storage->disconnect; } @@ -855,6 +872,7 @@ sub dbconnect { RaiseError => $complain, ShowErrorStatement => $complain, PrintError => 0, + %{ $self->{connect_info_opts} || {} }, }, ]); @@ -966,8 +984,8 @@ sub create { id1 INTEGER NOT NULL, iD2 INTEGER NOT NULL, dat VARCHAR(8), - from_id INTEGER, - to_id INTEGER, + from_id INTEGER $self->{null}, + to_id INTEGER $self->{null}, PRIMARY KEY (id1,iD2), FOREIGN KEY (from_id) REFERENCES loader_test4 (id), FOREIGN KEY (to_id) REFERENCES loader_test4 (id)