NAME
DBICTest - Library to be used by DBIx::Class test scripts
SYNOPSIS
use lib qw(t/lib);
use DBICTest;
use Test::More;
my $schema = DBICTest->init_schema();
DESCRIPTION
This module provides the basic utilities to write tests against DBIx::Class.
EXPORTS
The module does not export anything by default, nor provides individual function exports in the conventional sense. Instead the following tags are recognized:
:DiffSQL
Same as use SQL::Abstract::Test qw(is_same_sql_bind is_same_sql is_same_bind)
:GlobalLock
Some tests are very time sensitive and need to run on their own, without being disturbed by anything else grabbing CPU or disk IO. Hence why everything using DBICTest
grabs a shared lock, and the few tests that request a :GlobalLock
will ask for an exclusive one and block until they can get it.
METHODS
init_schema
my $schema = DBICTest->init_schema(
no_deploy=>1,
no_populate=>1,
storage_type=>'::DBI::Replicated',
storage_type_args=>{
balancer_type=>'DBIx::Class::Storage::DBI::Replicated::Balancer::Random'
},
);
This method removes the test SQLite database in t/var/DBIxClass.db and then creates a new, empty database.
This method will call deploy_schema() by default, unless the no_deploy
flag is set.
Also, by default, this method will call populate_schema() by default, unless the no_deploy
or no_populate
flags are set.
deploy_schema
DBICTest->deploy_schema( $schema );
This method does one of two things to the schema. It can either call the experimental $schema->deploy() if the DBICTEST_SQLT_DEPLOY environment variable is set, otherwise the default is to read in the t/lib/sqlite.sql file and execute the SQL within. Either way you end up with a fresh set of tables for testing.
populate_schema
DBICTest->populate_schema( $schema );
After you deploy your schema you can use this method to populate the tables with test data.