Probably avoids some potential page/search bugs
[dbsrgits/DBIx-Class.git] / t / run / 11mysql.tl
CommitLineData
0567538f 1sub run_tests {
2
3my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/};
4
5#warn "$dsn $user $pass";
6
7plan skip_all, 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test'
8 unless ($dsn && $user);
9
10plan tests => 4;
11
3712e4f4 12DBICTest->class("Schema")->compose_connection('MySQLTest' => $dsn, $user, $pass);
0567538f 13
14my $dbh = MySQLTest::Artist->storage->dbh;
15
16$dbh->do("DROP TABLE IF EXISTS artist;");
17
18$dbh->do("CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255));");
19
20#'dbi:mysql:host=localhost;database=dbic_test', 'dbic_test', '');
21
22MySQLTest::Artist->load_components('PK::Auto::MySQL');
23
24# test primary key handling
25my $new = MySQLTest::Artist->create({ name => 'foo' });
26ok($new->artistid, "Auto-PK worked");
27
28# test LIMIT support
29for (1..6) {
30 MySQLTest::Artist->create({ name => 'Artist ' . $_ });
31}
32my $it = MySQLTest::Artist->search( {},
33 { rows => 3,
34 offset => 2,
35 order_by => 'artistid' }
36);
37is( $it->count, 3, "LIMIT count ok" );
38is( $it->next->name, "Artist 2", "iterator->next ok" );
39$it->next;
40$it->next;
41is( $it->next, undef, "next past end of resultset ok" );
42
43# clean up our mess
44$dbh->do("DROP TABLE artist");
45
46}
47
481;