PK::Auto::Pg bug fix, only checks primary keys
[dbsrgits/DBIx-Class.git] / t / run / 12pg.tl
1 sub run_tests {
2
3 my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/};
4
5 #warn "$dsn $user $pass";
6
7 plan skip_all, 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test'
8   . ' (note: creates and drops a table named artist!)' unless ($dsn && $user);
9
10 plan tests => 2;
11
12 DBICTest::Schema->compose_connection('PgTest' => $dsn, $user, $pass);
13
14 my $dbh = PgTest::Artist->storage->dbh;
15
16 $dbh->do("CREATE TABLE artist (artistid serial PRIMARY KEY, name VARCHAR(255));");
17
18 PgTest::Artist->load_components('PK::Auto::Pg');
19
20 my $new = PgTest::Artist->create({ name => 'foo' });
21
22 is($new->artistid, 1, "Auto-PK worked");
23
24 $new = PgTest::Artist->create({ name => 'bar' });
25
26 is($new->artistid, 2, "Auto-PK worked");
27
28 $dbh->do("DROP TABLE artist;");
29
30 }
31
32 1;