X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Frun%2F12pg.tl;h=d71e39c84ce99f5d947d6a55a7ec6141e92bc8f5;hb=4b8dcc58874223164d4a379a5db4a9cb737d7c7a;hp=e79a687ba34c8aaf986fd030b91523d190c569e3;hpb=3712e4f41b929456d8fad713ca702e4a48e9a940;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/run/12pg.tl b/t/run/12pg.tl index e79a687..d71e39c 100644 --- a/t/run/12pg.tl +++ b/t/run/12pg.tl @@ -1,5 +1,5 @@ sub run_tests { - +my $schema = shift; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; #warn "$dsn $user $pass"; @@ -7,15 +7,16 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; plan skip_all, 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' . ' (note: creates and drops a table named artist!)' unless ($dsn && $user); -plan tests => 2; - -DBICTest->class("Schema")->compose_connection('PgTest' => $dsn, $user, $pass); +plan tests => 4; -my $dbh = PgTest::Artist->storage->dbh; +DBICTest::Schema->compose_connection('PgTest' => $dsn, $user, $pass); -$dbh->do("CREATE TABLE artist (artistid serial PRIMARY KEY, name VARCHAR(255));"); +my $dbh = PgTest->schema->storage->dbh; +PgTest->schema->source("Artist")->name("testschema.artist"); +$dbh->do("CREATE SCHEMA testschema;"); +$dbh->do("CREATE TABLE testschema.artist (artistid serial PRIMARY KEY, name VARCHAR(255), charfield CHAR(10));"); -PgTest::Artist->load_components('PK::Auto::Pg'); +PgTest::Artist->load_components('PK::Auto'); my $new = PgTest::Artist->create({ name => 'foo' }); @@ -25,7 +26,37 @@ $new = PgTest::Artist->create({ name => 'bar' }); is($new->artistid, 2, "Auto-PK worked"); -$dbh->do("DROP TABLE artist;"); +my $test_type_info = { + 'artistid' => { + 'data_type' => 'integer', + 'is_nullable' => 0, + 'size' => 4, + }, + 'name' => { + 'data_type' => 'character varying', + 'is_nullable' => 1, + 'size' => 255, + 'default_value' => undef, + }, + 'charfield' => { + 'data_type' => 'character', + 'is_nullable' => 1, + 'size' => 10, + 'default_value' => undef, + }, +}; + + +my $type_info = PgTest->schema->storage->columns_info_for('testschema.artist'); +my $artistid_defval = delete $type_info->{artistid}->{default_value}; +like($artistid_defval, + qr/^nextval\('([^\.]*\.){0,1}artist_artistid_seq'::(?:text|regclass)\)/, + 'columns_info_for - sequence matches Pg get_autoinc_seq expectations'); +is_deeply($type_info, $test_type_info, + 'columns_info_for - column data types'); + +$dbh->do("DROP TABLE testschema.artist;"); +$dbh->do("DROP SCHEMA testschema;"); }