Commit | Line | Data |
0567538f |
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' |
b6b65a3e |
8 | . ' (note: creates and drops a table named artist!)' unless ($dsn && $user); |
0567538f |
9 | |
b6b65a3e |
10 | plan tests => 2; |
0567538f |
11 | |
3712e4f4 |
12 | DBICTest->class("Schema")->compose_connection('PgTest' => $dsn, $user, $pass); |
0567538f |
13 | |
14 | my $dbh = PgTest::Artist->storage->dbh; |
15 | |
0567538f |
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 | |
b6b65a3e |
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;"); |
0567538f |
29 | |
30 | } |
31 | |
32 | 1; |