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