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