[Dbix-class] Dumping fixtures and loading in test script

Adam Witney awitney at sgul.ac.uk
Mon Nov 4 15:33:01 GMT 2013


Hi,

I am having trouble getting fixtures dumped and then reloaded in my test 
scripts. The first problem is dumping with this script snippet:

use DBIx::Class::Fixtures;
use RCA::Schema;
use lib qw(lib);

my $schema = RCA::Schema->connect('dbi:Pg:dbname=dev', 'user', '');

my $fixtures = DBIx::Class::Fixtures->new({
      config_dir => 't/var/configs', debug => 1
});

$fixtures->dump({
    all => 1,
    schema => $schema,
    directory => 't/var/fixtures'
});

This produces this output:

generating  fixtures
- creating /tmp/BbI5ISYRxw
- dumping Episode
- moving temp dir to t/var/fixtures
- clearing tmp dir /tmp/BbI5ISYRxw
done

but something seems to have gone wrong as the fixtures are still in the 
tmp dir

$ ls t/var/fixtures/
_config_set  _dumper_version

$ ls /tmp/BbI5ISYRxw/
episode

The next problem is that I can't yet figure out how to load the fixtures 
in my test scripts, I have a conf here:

$ less t/etc/schema.conf
schema_class RCA::Schema
connect_info dbi:Pg:dbname=dev
user user
force_drop_table 1
keep_db 1

And a test script

$ less t/model/Episode.t
use Test::More;
use Test::DBIx::Class qw(:resultsets);

fixtures_ok 'basic'
       => 'installed the basic fixtures from configuration files';
ok my $episode_id = Episode->find(1) => 'Episode found ok';

but of course, the test fails.

Any pointers as to what I am missing?

Thanks for any help

Adam




More information about the DBIx-Class mailing list