X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Finflate%2Fdatetime_msaccess.t;h=f01219987aee14898faf5b576483fffef71fa2cf;hb=21aa86aae083ccb5b94ba994dec030627e95e40b;hp=7f62e4ea2bb7a0864efb4c8f3248c2526a4d6e61;hpb=726c8f65ef37b47aad62e29a306f64528a00f65d;p=dbsrgits%2FDBIx-Class.git diff --git a/t/inflate/datetime_msaccess.t b/t/inflate/datetime_msaccess.t index 7f62e4e..f012199 100644 --- a/t/inflate/datetime_msaccess.t +++ b/t/inflate/datetime_msaccess.t @@ -2,40 +2,49 @@ use strict; use warnings; use Test::More; -use Test::Exception; use Scope::Guard (); use Try::Tiny; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSACCESS_ODBC_${_}" } qw/DSN USER PASS/}; my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_MSACCESS_ADO_${_}" } qw/DSN USER PASS/}; +plan skip_all => 'Test needs ' . + (join ' and ', map { $_ ? $_ : () } + DBIx::Class::Optional::Dependencies->req_missing_for('test_dt'), + (join ' or ', map { $_ ? $_ : () } + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_msaccess_odbc'), + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_msaccess_ado'))) + unless + DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt') && ( + $dsn && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_msaccess_odbc') + or + $dsn2 && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_msaccess_ado')) + or (not $dsn || $dsn2); + plan skip_all => <<'EOF' unless $dsn || $dsn2; -Set $ENV{DBICTEST_MSACCESS_ODBC_DSN} and/or $ENV{DBICTEST_MSACCESS_ADO_DSN} (and optionally _USER and _PASS) to run these tests.\nWarning: this test drops and creates the table 'track'. +Set $ENV{DBICTEST_MSACCESS_ODBC_DSN} and/or $ENV{DBICTEST_MSACCESS_ADO_DSN} (and optionally _USER and _PASS) to run these tests. +Warning: this test drops and creates the table 'track'. EOF -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt'); - my @connect_info = ( [ $dsn, $user || '', $pass || '' ], [ $dsn2, $user2 || '', $pass2 || '' ], ); -my $schema; - for my $connect_info (@connect_info) { my ($dsn, $user, $pass) = @$connect_info; next unless $dsn; - $schema = DBICTest::Schema->connect($dsn, $user, $pass, { + my $schema = DBICTest::Schema->connect($dsn, $user, $pass, { on_connect_call => 'datetime_setup', quote_names => 1, }); - my $guard = Scope::Guard->new(\&cleanup); + my $guard = Scope::Guard->new(sub { cleanup($schema) }); try { local $^W = 0; $schema->storage->dbh->do('DROP TABLE track') }; $schema->storage->dbh->do(<<"SQL"); @@ -71,6 +80,7 @@ done_testing; # clean up our mess sub cleanup { + my $schema = shift; # have to reconnect to drop a table that's in use if (my $storage = eval { $schema->storage }) { local $^W = 0;