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

Adam Witney awitney at sgul.ac.uk
Tue Nov 5 16:36:20 GMT 2013


Thanks Rob, although I'm not sure how that makes it any easier, do you 
have an example script?

Thanks

Adam

On 4. 11. 2013 15:53, Rob Kinyon wrote:
> 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
>
>
>



More information about the DBIx-Class mailing list