From: Brian Cassidy Date: Fri, 19 Aug 2005 15:13:51 +0000 (+0000) Subject: Added LIMIT tests X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=861c08e43834137c93ad4eb8076191747c09da86;p=dbsrgits%2FDBIx-Class-Historic.git Added LIMIT tests --- diff --git a/t/14mssql.t b/t/14mssql.t index bd8e3e3..a164c2f 100644 --- a/t/14mssql.t +++ b/t/14mssql.t @@ -10,9 +10,9 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/}; plan skip_all, 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test' unless ($dsn); -plan tests => 1; +plan tests => 4; -DBICTest::Schema->compose_connection('MSSQLTest' => $dsn, $user, $pass); +DBICTest::Schema->compose_connection( 'MSSQLTest' => $dsn, $user, $pass ); my $dbh = MSSQLTest::Artist->storage->dbh; @@ -23,8 +23,26 @@ $dbh->do("CREATE TABLE artist (artistid INT IDENTITY PRIMARY KEY, name VARCHAR(2 MSSQLTest::Artist->load_components('PK::Auto::MSSQL'); -my $new = MSSQLTest::Artist->create({ name => 'foo' }); - +# Test PK +my $new = MSSQLTest::Artist->create( { name => 'foo' } ); ok($new->artistid, "Auto-PK worked"); +# Test LIMIT +for (1..6) { + MSSQLTest::Artist->create( { name => 'Artist ' . $_ } ); +} + +my $it = MSSQLTest::Artist->search( { }, + { rows => 3, + offset => 2, + order_by => 'artistid' + } +); + +is( $it->count, 3, "LIMIT count ok" ); +is( $it->next->name, "Artist 2", "iterator->next ok" ); +$it->next; +$it->next; +is( $it->next, undef, "next past end of resultset ok" ); + 1;