X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F94versioning.t;h=c3751b205a0b446f3fa94d8176e07d04509790ec;hb=c0329273268971824784f239f32c7246e68da9c5;hp=146c7c31fa8919a7d9a71c19c34b9698c9d7cb44;hpb=f3ec358e1859eb4ab179fda0d93e8c0336c0f8a9;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/94versioning.t b/t/94versioning.t index 146c7c3..c3751b2 100644 --- a/t/94versioning.t +++ b/t/94versioning.t @@ -1,3 +1,6 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } +use DBIx::Class::Optional::Dependencies -skip_all_without => qw(deploy test_rdbms_mysql); + use strict; use warnings; @@ -9,32 +12,20 @@ use Path::Class; use File::Copy; use Time::HiRes qw/time sleep/; -use lib qw(t/lib); -use DBICTest; - -my ($dsn, $user, $pass); - -BEGIN { - ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}; - - plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test' - unless ($dsn); - require DBIx::Class; - plan skip_all => - 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('deploy') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('deploy'); +use DBICTest; +use DBIx::Class::_Util 'sigwarn_silencer'; - plan skip_all => - 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_mysql') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_mysql'); -} +my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}; # this is just to grab a lock { my $s = DBICTest::Schema->connect($dsn, $user, $pass); } +# in case it came from the env +$ENV{DBIC_NO_VERSION_CHECK} = 0; + use_ok('DBICVersion_v1'); my $version_table_name = 'dbix_class_schema_versions'; @@ -164,7 +155,7 @@ my $schema_v3 = DBICVersion::Schema->connect($dsn, $user, $pass, { ignore_versio # attempt v1 -> v3 upgrade { - local $SIG{__WARN__} = sub { warn $_[0] if $_[0] !~ /Attempting upgrade\.$/ }; + local $SIG{__WARN__} = sigwarn_silencer( qr/Attempting upgrade\.$/ ); $schema_v3->upgrade(); is($schema_v3->get_db_version(), '3.0', 'db version number upgraded'); } @@ -193,7 +184,7 @@ my $schema_v3 = DBICVersion::Schema->connect($dsn, $user, $pass, { ignore_versio # Then attempt v1 -> v3 upgrade { - local $SIG{__WARN__} = sub { warn $_[0] if $_[0] !~ /Attempting upgrade\.$/ }; + local $SIG{__WARN__} = sigwarn_silencer( qr/Attempting upgrade\.$/ ); $schema_v3->upgrade(); is($schema_v3->get_db_version(), '3.0', 'db version number upgraded to 3.0'); @@ -247,7 +238,8 @@ my $schema_v3 = DBICVersion::Schema->connect($dsn, $user, $pass, { ignore_versio $schema_v2->deploy; } - local $SIG{__WARN__} = sub { warn $_[0] if $_[0] !~ /Attempting upgrade\.$/ }; + local $SIG{__WARN__} = sigwarn_silencer( qr/Attempting upgrade\.$/ ); + $schema_v2->upgrade(); is($schema_v2->get_db_version(), '3.0', 'Fast deploy/upgrade'); @@ -280,6 +272,17 @@ my $schema_v3 = DBICVersion::Schema->connect($dsn, $user, $pass, { ignore_versio ok($get_db_version_run == 0, "attributes pulled from list connect_info"); } +# at this point we have v1, v2 and v3 still connected +# make sure they are the only connections and everything else is gone +is + scalar( grep + { defined $_ and $_->{Active} } + map + { @{$_->{ChildHandles}} } + values %{ { DBI->installed_drivers } } + ), 3, "Expected number of connections at end of script" +; + END { unless ($ENV{DBICTEST_KEEP_VERSIONING_DDL}) { $ddl_dir->rmtree;