DBICx::TestDatabase - create a temporary database from a DBIx::Class::Schema
Given a DBIx::Class::Schema at MyApp::Schema, create a test database like this:
MyApp::Schema
use DBICx::TestDatabase; my $schema = DBICx::TestDatabase->new('MyApp::Schema');
Then you can use $schema normally:
$schema
$schema->resultset('Blah')->create({ blah => '123' });
When your program exits, the temporary database will go away.
This module creates a temporary SQLite database, deploys your DBIC schema, and then connects to it. This lets you easily test your DBIC schema. Since you have a fresh database for every test, you don't have to worry about cleaning up after your tests, ordering of tests affecting failure, etc.
Loads $schema and returns a connection to it.
Alias for new.
Jonathan Rockway <jrockway@cpan.org>
<jrockway@cpan.org>
Copyright (c) 2007 Jonathan Rockway.
This program is free software. You may use, modify, and redistribute it under the same terms as Perl itself.
To install DBICx::TestDatabase, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBICx::TestDatabase
CPAN shell
perl -MCPAN -e shell install DBICx::TestDatabase
For more information on module installation, please visit the detailed CPAN module installation guide.