A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Perl Postgres test fixtures

Test::PostgreSQL approach:

my $postgres_db = Test::PostgreSQL->new;
my $test_schema = MyDBIC::Schema->connect( $postgres_db->dsn );
my $test_migration = DBIx::Class::Migration->new(
schema => $test_schema,
target_dir => 'share',
);
$test_migration->install;
$t->app->helper( 'schema' => sub { $test_schema } );


Test::DBIx::Class approach:

use Test::DBIx::Class {
schema_class => 'MyDBIC::Schema',
connect_info => { dsn => 'dbi:Pg:' },
};
my $test_schema = Schema;
# This works, but not sure why it's necessary to duplicate the fixtures
# that are already in share/migrations/PostgreSQL/deploy/1
fixtures_ok [
FooTable => [
[ qw/code/ ],
[ qw/CREATED/ ],
],
# Or possibly
# fixtures_ok 'basic' => 'installed the basic fixtures from configuration files';
# DBIx::Class::Fixtures->new({config_dir => $fixtures_path})
# ->populate({no_deploy => 1, schema => $test_schema, directory => "$fixtures_path"});
$t->app->helper( 'payments_schema' => sub { $test_schema } );