Commit | Line | Data |
70350518 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
eef2ff6c |
7 | |
8 | my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/}; |
9 | |
10 | #warn "$dsn $user $pass"; |
11 | |
70350518 |
12 | plan skip_all => 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test' |
eef2ff6c |
13 | unless ($dsn); |
14 | |
15 | plan tests => 4; |
16 | |
58d387fe |
17 | DBICTest::Schema->compose_connection( 'MSSQLTest' => $dsn, $user, $pass ); |
eef2ff6c |
18 | |
19 | my $dbh = MSSQLTest->schema->storage->dbh; |
20 | |
21 | $dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL |
22 | DROP TABLE artist"); |
23 | |
24 | $dbh->do("CREATE TABLE artist (artistid INT IDENTITY PRIMARY KEY, name VARCHAR(255));"); |
25 | |
26 | MSSQLTest::Artist->load_components('PK::Auto::MSSQL'); |
27 | |
28 | # Test PK |
29 | my $new = MSSQLTest::Artist->create( { name => 'foo' } ); |
30 | ok($new->artistid, "Auto-PK worked"); |
31 | |
32 | # Test LIMIT |
33 | for (1..6) { |
34 | MSSQLTest::Artist->create( { name => 'Artist ' . $_ } ); |
35 | } |
36 | |
37 | my $it = MSSQLTest::Artist->search( { }, |
38 | { rows => 3, |
39 | offset => 2, |
40 | order_by => 'artistid' |
41 | } |
42 | ); |
43 | |
44 | is( $it->count, 3, "LIMIT count ok" ); |
f48dd03f |
45 | ok( $it->next->name, "iterator->next ok" ); |
eef2ff6c |
46 | $it->next; |
47 | $it->next; |
48 | is( $it->next, undef, "next past end of resultset ok" ); |
49 | |