X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F746db2_400.t;h=29b7ff12f3022399385cbc5194b3e7ecc7f814bb;hb=8f4b5c084378a4c457c8893404aded4398c1d811;hp=6c2344cd60ef414af4434d64ce411ce144ecc38f;hpb=d6915f449e2d68ac184d6bc616043fd605913757;p=dbsrgits%2FDBIx-Class.git diff --git a/t/746db2_400.t b/t/746db2_400.t index 6c2344c..29b7ff1 100644 --- a/t/746db2_400.t +++ b/t/746db2_400.t @@ -1,5 +1,5 @@ use strict; -use warnings; +use warnings; use Test::More; use lib qw(t/lib); @@ -12,30 +12,37 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_400_${_}" } qw/DSN USER PASS/ # Probably best to pass the DBQ option in the DSN to specify a specific # libray. Something like: # DBICTEST_DB2_400_DSN='dbi:ODBC:dsn=MyAS400;DBQ=MYLIB' -plan skip_all, 'Set $ENV{DBICTEST_DB2_400_DSN}, _USER and _PASS to run this test' +plan skip_all => 'Set $ENV{DBICTEST_DB2_400_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); plan tests => 6; -DBICTest::Schema->compose_connection('DB2Test' => $dsn, $user, $pass); +my $schema = DBICTest::Schema->connect($dsn, $user, $pass); -my $dbh = DB2Test->schema->storage->dbh; +my $dbh = $schema->storage->dbh; -$dbh->do("DROP TABLE artist", { RaiseError => 0, PrintError => 0 }); +eval { $dbh->do("DROP TABLE artist") }; -$dbh->do("CREATE TABLE artist (artistid INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), name VARCHAR(255), charfield CHAR(10))"); +$dbh->do(<<''); +CREATE TABLE artist ( + artistid INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + name VARCHAR(255), + rank INTEGER default 13 not null, + charfield CHAR(10) +) -DB2Test::Artist->load_components('PK::Auto'); +# Just to test loading, already in Core +$schema->class('Artist')->load_components('PK::Auto'); # test primary key handling -my $new = DB2Test::Artist->create({ name => 'foo' }); +my $new = $schema->resultset('Artist')->create({ name => 'foo' }); ok($new->artistid, "Auto-PK worked"); # test LIMIT support for (1..6) { - DB2Test::Artist->create({ name => 'Artist ' . $_ }); + $schema->resultset('Artist')->create({ name => 'Artist ' . $_ }); } -my $it = DB2Test::Artist->search( {}, +my $it = $schema->resultset('Artist')->search( {}, { rows => 3, order_by => 'artistid' } @@ -57,6 +64,11 @@ my $test_type_info = { 'is_nullable' => 1, 'size' => 255 }, + 'rank' => { + 'data_type' => 'INTEGER', + 'is_nullable' => 0, + 'size' => 10, + }, 'charfield' => { 'data_type' => 'CHAR', 'is_nullable' => 1, @@ -65,11 +77,11 @@ my $test_type_info = { }; -my $type_info = DB2Test->schema->storage->columns_info_for('artist'); +my $type_info = $schema->storage->columns_info_for('artist'); is_deeply($type_info, $test_type_info, 'columns_info_for - column data types'); - - # clean up our mess -$dbh->do("DROP TABLE artist"); - +END { + my $dbh = eval { $schema->storage->_dbh }; + $dbh->do("DROP TABLE artist") if $dbh; +}