X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F745db2.t;h=3ba85794b1e933ba9ed6f500ef18861afe9fec32;hb=d0f52dd4982eca28140a950367a203b9b466c3d2;hp=5d628e800d18d937e5e746a8b164b08af2a3e632;hpb=70c29d322398ebe3b6d5e24e032222182e61fed9;p=dbsrgits%2FDBIx-Class.git diff --git a/t/745db2.t b/t/745db2.t index 5d628e8..3ba8579 100644 --- a/t/745db2.t +++ b/t/745db2.t @@ -12,7 +12,7 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Set $ENV{DBICTEST_DB2_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); -plan tests => 6; +plan tests => 9; my $schema = DBICTest::Schema->connect($dsn, $user, $pass); @@ -25,24 +25,36 @@ $dbh->do("CREATE TABLE artist (artistid INTEGER GENERATED BY DEFAULT AS IDENTITY # This is in core, just testing that it still loads ok $schema->class('Artist')->load_components('PK::Auto'); +my $ars = $schema->resultset('Artist'); + # test primary key handling -my $new = $schema->resultset('Artist')->create({ name => 'foo' }); +my $new = $ars->create({ name => 'foo' }); ok($new->artistid, "Auto-PK worked"); -# test LIMIT support +my $init_count = $ars->count; for (1..6) { - $schema->resultset('Artist')->create({ name => 'Artist ' . $_ }); + $ars->create({ name => 'Artist ' . $_ }); } -my $it = $schema->resultset('Artist')->search( {}, - { rows => 3, - order_by => 'artistid' - } +is ($ars->count, $init_count + 6, 'Simple count works'); + +# test LIMIT support +my $it = $ars->search( {}, + { + rows => 3, + order_by => 'artistid' + } ); is( $it->count, 3, "LIMIT count ok" ); + +my @all = $it->all; +is (@all, 3, 'Number of ->all objects matches count'); + +$it->reset; is( $it->next->name, "foo", "iterator->next ok" ); -$it->next; +is( $it->next->name, "Artist 1", "iterator->next ok" ); is( $it->next->name, "Artist 2", "iterator->next ok" ); -is( $it->next, undef, "next past end of resultset ok" ); +is( $it->next, undef, "next past end of resultset ok" ); # this can not succeed if @all > 3 + my $test_type_info = { 'artistid' => { @@ -73,5 +85,6 @@ is_deeply($type_info, $test_type_info, 'columns_info_for - column data types'); # clean up our mess END { + my $dbh = eval { $schema->storage->_dbh }; $dbh->do("DROP TABLE artist") if $dbh; }