Test::PostgreSQL approach:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } ); |