X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F749sqlanywhere.t;h=ed9c382cab6c0e86ed62223ec7cf2a38e488996e;hb=8aae794001ecccdb26c2bbd1b92c97bba9e65d79;hp=816186e195f583fc910ba288bc8f4a0b7ed74924;hpb=199fbc453ec03891d0e156d7353c5e992ba4de47;p=dbsrgits%2FDBIx-Class.git diff --git a/t/749sqlanywhere.t b/t/749sqlanywhere.t index 816186e..ed9c382 100644 --- a/t/749sqlanywhere.t +++ b/t/749sqlanywhere.t @@ -1,12 +1,13 @@ +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 DBIx::Class::Optional::Dependencies (); -use lib qw(t/lib); +use DBIx::Class::_Util 'scope_guard'; + use DBICTest; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SQLANYWHERE_${_}" } qw/DSN USER PASS/}; @@ -48,7 +49,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; @@ -177,7 +178,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). @@ -224,41 +225,61 @@ SQL ); diag $@ if $@; - my $row_from_db = try { $schema->resultset('ArtistGUID') - ->search({ name => 'mtfnpy' })->first } - catch { diag $_ }; + my $row_from_db; + lives_ok { + $row_from_db = $schema->resultset('ArtistGUID')->search({ name => 'mtfnpy' })->first + }; - is try { $row_from_db->artistid }, $row->artistid, - 'PK GUID round trip (via ->search->next)'; + is( + eval { $row_from_db->artistid }, + $row->artistid, + 'PK GUID round trip (via ->search->next)' + ); - is try { $row_from_db->a_guid }, $row->a_guid, - 'NON-PK GUID round trip (via ->search->next)'; + is( + eval { $row_from_db->a_guid }, + $row->a_guid, + 'NON-PK GUID round trip (via ->search->next)' + ); - $row_from_db = try { $schema->resultset('ArtistGUID') - ->find($row->artistid) } - catch { diag $_ }; + lives_ok { + $row_from_db = $schema->resultset('ArtistGUID')->find($row->artistid) + }; - is try { $row_from_db->artistid }, $row->artistid, - 'PK GUID round trip (via ->find)'; + is( + eval { $row_from_db->artistid }, + $row->artistid, + 'PK GUID round trip (via ->find)' + ); - is try { $row_from_db->a_guid }, $row->a_guid, - 'NON-PK GUID round trip (via ->find)'; + is( + eval { $row_from_db->a_guid }, + $row->a_guid, + 'NON-PK GUID round trip (via ->find)' + ); - ($row_from_db) = try { $schema->resultset('ArtistGUID') - ->search({ name => 'mtfnpy' })->all } - catch { diag $_ }; + lives_ok { + ($row_from_db) = $schema->resultset('ArtistGUID')->search({ name => 'mtfnpy' })->all + }; - is try { $row_from_db->artistid }, $row->artistid, - 'PK GUID round trip (via ->search->all)'; + is( + eval { $row_from_db->artistid }, + $row->artistid, + 'PK GUID round trip (via ->search->all)' + ); - is try { $row_from_db->a_guid }, $row->a_guid, - 'NON-PK GUID round trip (via ->search->all)'; + is( + eval { $row_from_db->a_guid }, + $row->a_guid, + 'NON-PK GUID round trip (via ->search->all)' + ); } } done_testing; sub cleanup { + my $schema = shift; eval { $schema->storage->dbh->do("DROP TABLE $_") } for qw/artist artist_guid bindtype_test/; }