X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F750firebird.t;h=fac50d560fb325fe195b61c6d39830bc0d8a5d2b;hb=399b9455;hp=d55474b64310283f40a87ff3e1a9d1e49f576617;hpb=5346c8ff29968a334e9b3269be7c06c3e3235d08;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/750firebird.t b/t/750firebird.t index d55474b..fac50d5 100644 --- a/t/750firebird.t +++ b/t/750firebird.t @@ -1,12 +1,15 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + use strict; use warnings; use Test::More; use Test::Exception; use DBIx::Class::Optional::Dependencies (); -use Scope::Guard (); +use DBIx::Class::_Util 'scope_guard'; +use List::Util 'shuffle'; use Try::Tiny; -use lib qw(t/lib); + use DBICTest; my $env2optdep = { @@ -25,8 +28,6 @@ plan skip_all => join (' ', 'and "nonpkid_seq" and the trigger "artist_bi".', ) unless grep { $ENV{"${_}_DSN"} } keys %$env2optdep; -# tests stolen from 749sybase_asa.t - # Example DSNs: # dbi:Firebird:db=/var/lib/firebird/2.5/data/hlaghdb.fdb # dbi:InterBase:db=/var/lib/firebird/2.5/data/hlaghdb.fdb @@ -36,14 +37,12 @@ plan skip_all => join (' ', my $schema; -for my $prefix (keys %$env2optdep) { SKIP: { - - my ($dsn, $user, $pass) = map { $ENV{"${prefix}_$_"} } qw/DSN USER PASS/; +for my $prefix (shuffle keys %$env2optdep) { SKIP: { - next unless $dsn; + DBIx::Class::Optional::Dependencies->skip_without( $env2optdep->{$prefix} ); - skip ("Testing with ${prefix}_DSN needs " . DBIx::Class::Optional::Dependencies->req_missing_for( $env2optdep->{$prefix} ), 1) - unless DBIx::Class::Optional::Dependencies->req_ok_for($env2optdep->{$prefix}); + my ($dsn, $user, $pass) = map { $ENV{"${prefix}_$_"} } qw/DSN USER PASS/; + note "Testing with ${prefix}_DSN"; $schema = DBICTest::Schema->connect($dsn, $user, $pass, { auto_savepoint => 1, @@ -52,7 +51,7 @@ for my $prefix (keys %$env2optdep) { SKIP: { }); my $dbh = $schema->storage->dbh; - my $sg = Scope::Guard->new(\&cleanup); + my $sg = scope_guard { cleanup($schema) }; eval { $dbh->do(q[DROP TABLE "artist"]) }; $dbh->do(<txn_do(sub { + my ($schema, $ars) = @_; eval { $schema->txn_do(sub { $ars->create({ name => 'in_savepoint' }); @@ -135,7 +135,7 @@ EOF 'savepoint rolled back'); $ars->create({ name => 'in_outer_txn' }); die "rolling back outer txn"; - }); + }, $schema, $ars); } qr/rolling back outer txn/, 'correct exception for rollback'; @@ -252,6 +252,14 @@ EOF } 'inferring generator from trigger source works'; } + # at this point there should be no active statements + # (finish() was called everywhere, either explicitly via + # reset() or on DESTROY) + for (keys %{$schema->storage->dbh->{CachedKids}}) { + fail("Unreachable cached statement still active: $_") + if $schema->storage->dbh->{CachedKids}{$_}->FETCH('Active'); + } + # test blobs (stolen from 73oracle.t) eval { $dbh->do('DROP TABLE "bindtype_test"') }; $dbh->do(q[ @@ -305,6 +313,8 @@ done_testing; # clean up our mess sub cleanup { + my $schema = shift; + my $dbh; eval { $schema->storage->disconnect; # to avoid object FOO is in use errors