X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F749sqlanywhere.t;h=d4067b5bfd7397b11d5d89a81d6c5a2d0c76f504;hb=c40b5744f85a8ffc2da494464655936387c04251;hp=71898988166016a117f8b6adf22fa6633fad7dcc;hpb=4b3515a668346eb157141db0d44d4c3282305c72;p=dbsrgits%2FDBIx-Class.git diff --git a/t/749sqlanywhere.t b/t/749sqlanywhere.t index 7189898..d4067b5 100644 --- a/t/749sqlanywhere.t +++ b/t/749sqlanywhere.t @@ -1,20 +1,34 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + use strict; use warnings; use Test::More; use Test::Exception; -use Scope::Guard (); use Try::Tiny; -use lib qw(t/lib); +use DBIx::Class::Optional::Dependencies (); +use DBIx::Class::_Util 'scope_guard'; + use DBICTest; +my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SQLANYWHERE_${_}" } qw/DSN USER PASS/}; +my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_SQLANYWHERE_ODBC_${_}" } qw/DSN USER PASS/}; + +plan skip_all => 'Test needs ' . + (join ' or ', map { $_ ? $_ : () } + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_sqlanywhere'), + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_sqlanywhere_odbc')) + unless + $dsn && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_sqlanywhere') + or + $dsn2 && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_sqlanywhere_odbc') + or + (not $dsn || $dsn2); + DBICTest::Schema->load_classes('ArtistGUID'); # tests stolen from 748informix.t -my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SQLANYWHERE_${_}" } qw/DSN USER PASS/}; -my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_SQLANYWHERE_ODBC_${_}" } qw/DSN USER PASS/}; - plan skip_all => <<'EOF' unless $dsn || $dsn2; Set $ENV{DBICTEST_SQLANYWHERE_DSN} and/or $ENV{DBICTEST_SQLANYWHERE_ODBC_DSN}, _USER and _PASS to run these tests @@ -36,7 +50,7 @@ foreach my $info (@info) { auto_savepoint => 1 }); - my $guard = Scope::Guard->new(\&cleanup); + my $guard = scope_guard { cleanup($schema) }; my $dbh = $schema->storage->dbh; @@ -165,7 +179,7 @@ EOF ok($rs->find($id)->$type eq $binstr{$size}, "verified inserted $size $type" ); } } - + my @uuid_types = qw/uniqueidentifier uniqueidentifierstr/; # test uniqueidentifiers (and the cursor_class). @@ -247,6 +261,7 @@ SQL done_testing; sub cleanup { + my $schema = shift; eval { $schema->storage->dbh->do("DROP TABLE $_") } for qw/artist artist_guid bindtype_test/; }