DBICx::TestDatabase3pm
Create a temporary database from a dbix::class::schema
Usage
Given a DBIx::Class::Schema at "MyApp::Schema", create a test database like this:
use DBICx::TestDatabase;my $schema = DBICx::TestDatabase->new('MyApp::Schema');
Then you can use $schema normally:
$schema->resultset('Blah')->create({ blah => '123' });
When your program exits, the temporary database will go away.
Overview
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.
Methods
new($schema)
Loads $schema and returns a connection to it.
connect
Alias for new.
Environment
You can control the behavior of this module at runtime by setting environment variables.
Dbic_keep_test
If this variable is true, then the test database will not be deleted at "END" time. Instead, a message containing the paths of the test databases will be printed.
This is good if you want to look at the database your test generated, for debugging.
(Note that the database will never exist on disk if you don't set this to a true value.)
Releases
9 releases since Debian 5.0 (Lenny); the text changed 4 times.