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 | |
a953d8d9 |
11 | plan tests => 3; |
0567538f |
12 | |
70fe6d6e |
13 | DBICTest::Schema->compose_connection('PgTest' => $dsn, $user, $pass); |
0567538f |
14 | |
a953d8d9 |
15 | my $dbh = PgTest->schema->storage->dbh; |
0567538f |
16 | |
103e3e03 |
17 | $dbh->do("CREATE TABLE artist (artistid serial PRIMARY KEY, name VARCHAR(255), charfield CHAR(10));"); |
0567538f |
18 | |
843f8ecd |
19 | PgTest::Artist->load_components('PK::Auto'); |
0567538f |
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 | |
a953d8d9 |
29 | my $test_type_info = { |
30 | 'artistid' => { |
103e3e03 |
31 | 'data_type' => 'integer', |
32 | 'is_nullable' => 0, |
33 | 'size' => 4 |
a953d8d9 |
34 | }, |
35 | 'name' => { |
103e3e03 |
36 | 'data_type' => 'character varying', |
37 | 'is_nullable' => 1, |
38 | 'size' => 255 |
39 | }, |
40 | 'charfield' => { |
41 | 'data_type' => 'character', |
a953d8d9 |
42 | 'is_nullable' => 1, |
103e3e03 |
43 | 'size' => 10 |
44 | }, |
a953d8d9 |
45 | }; |
46 | |
47 | my $type_info = PgTest->schema->storage->columns_info_for('artist'); |
48 | is_deeply($type_info, $test_type_info, 'columns_info_for - column data types'); |
49 | |
b6b65a3e |
50 | $dbh->do("DROP TABLE artist;"); |
0567538f |
51 | |
52 | } |
53 | |
54 | 1; |