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

Rob Kinyon rob.kinyon at gmail.com
Mon Nov 4 15:53:13 GMT 2013


This doesn't answer your question directly, but consider using
DBIx::Class::Sims instead for generating test data.

On Mon, Nov 4, 2013 at 10:33 AM, Adam Witney <awitney at sgul.ac.uk> wrote:
> 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
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk



-- 
Thanks,
Rob Kinyon
http://streamlined-book.blogspot.com/



More information about the DBIx-Class mailing list