Merge 'trunk' into 'DBIx-Class-current'
[dbsrgits/DBIx-Class-Historic.git] / t / run / 14mssql.tl
CommitLineData
1edaf6fe 1sub run_tests {
eef2ff6c 2my $schema = shift;
3
4my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/};
5
6#warn "$dsn $user $pass";
7
8plan skip_all, 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test'
9 unless ($dsn);
10
11plan tests => 4;
12
13$schema->compose_connection( 'MSSQLTest' => $dsn, $user, $pass );
14
15my $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
22MSSQLTest::Artist->load_components('PK::Auto::MSSQL');
23
24# Test PK
25my $new = MSSQLTest::Artist->create( { name => 'foo' } );
26ok($new->artistid, "Auto-PK worked");
27
28# Test LIMIT
29for (1..6) {
30 MSSQLTest::Artist->create( { name => 'Artist ' . $_ } );
31}
32
33my $it = MSSQLTest::Artist->search( { },
34 { rows => 3,
35 offset => 2,
36 order_by => 'artistid'
37 }
38);
39
40is( $it->count, 3, "LIMIT count ok" );
f48dd03f 41ok( $it->next->name, "iterator->next ok" );
eef2ff6c 42$it->next;
43$it->next;
44is( $it->next, undef, "next past end of resultset ok" );
45
46}
47
481;