From: Luke Saunders Date: Mon, 30 Jun 2008 20:07:13 +0000 (+0000) Subject: implemented versioning tests for version warns X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d0dfedc2ecb409f2f8befc523602e268ff844127;p=dbsrgits%2FDBIx-Class-Historic.git implemented versioning tests for version warns --- diff --git a/lib/DBIx/Class/Schema/Versioned.pm b/lib/DBIx/Class/Schema/Versioned.pm index d0cb53e..fa403ea 100644 --- a/lib/DBIx/Class/Schema/Versioned.pm +++ b/lib/DBIx/Class/Schema/Versioned.pm @@ -443,7 +443,6 @@ sub _on_connect # useful when connecting from scripts etc return if ($args->{ignore_version} || ($ENV{DBIC_NO_VERSION_CHECK} && !exists $args->{ignore_version})); - my $pversion = $self->get_db_version(); if($pversion eq $self->schema_version) diff --git a/t/94versioning.t b/t/94versioning.t index 1846f6b..5b1e603 100644 --- a/t/94versioning.t +++ b/t/94versioning.t @@ -18,7 +18,7 @@ BEGIN { eval "use DBD::mysql; use SQL::Translator 0.09;"; plan $@ ? ( skip_all => 'needs DBD::mysql and SQL::Translator 0.09 for testing' ) - : ( tests => 13 ); + : ( tests => 17 ); } my $version_table_name = 'dbix_class_schema_versions'; @@ -88,19 +88,30 @@ eval "use DBICVersionNew"; { my $schema_version = DBICVersion::Schema->connect($dsn, $user, $pass); eval { - $schema_version->storage->dbh->do("DROP TABLE IF EXISTS $version_table_name"); + $schema_version->storage->dbh->do("DELETE from $version_table_name"); }; + + my $warn = ''; + $SIG{__WARN__} = sub { $warn = shift }; $schema_version = DBICVersion::Schema->connect($dsn, $user, $pass); - # should warn + like($warn, qr/Your DB is currently unversioned/, 'warning detected without env var or attr'); + + # should warn + $warn = ''; $schema_version = DBICVersion::Schema->connect($dsn, $user, $pass, { ignore_version => 1 }); + is($warn, '', 'warning not detected with attr set'); # should not warn $ENV{DBIC_NO_VERSION_CHECK} = 1; + $warn = ''; $schema_version = DBICVersion::Schema->connect($dsn, $user, $pass); + is($warn, '', 'warning not detected with env var set'); # should not warn + $warn = ''; $schema_version = DBICVersion::Schema->connect($dsn, $user, $pass, { ignore_version => 0 }); + like($warn, qr/Your DB is currently unversioned/, 'warning detected without env var or attr'); # should warn }