CDTest - Small-scale DBIC test module
use lib qw(t/lib); use CDTest; use Test2::Bundle::More; my $schema = CDTest->init_schema;
This module provides a test DBIC schema in a real SQLite DB. Much of this was stolen and stripped down from DBICTest in DBIC's test platform.
my $schema = CDTest->init_schema( # Defaults no_connect => 0, no_deploy => 0, no_preclean => 0, no_populate => 0, ); my $schema = CDTest->init_schema( mass_populate => 100, );
This method creates a new, empty, in-memory SQLite database and then creates a new, empty database. If CDTEST_DSN, CDTEST_DBUSER, and CDTEST_DBPASS are specified, it will use that database instead. Make sure the database doesn't have any useful data in it.
CDTEST_DSN
CDTEST_DBUSER
CDTEST_DBPASS
This method will call "deploy_schema" by default, unless the no_deploy flag is set.
no_deploy
It will also call "clean_schema" by default, unless the no_preclean flag is set, or the SQLite in-memory DB is used (which is the default).
no_preclean
Also, by default, this method will call "populate_schema", unless the no_deploy or no_populate flags are set.
no_populate
If mass_populate or CDTEST_MASS_POPULATE is set, "mass_populate_schema" will be called instead, with the number of batches specified.
mass_populate
CDTEST_MASS_POPULATE
my $dbms_name = CDTest->dbms_name;
Acquires the driver name without connecting to anything.
CDTest->deploy_schema( $schema );
Deploys the sqlite.sql schema into the SQLite DB.
sqlite.sql
CDTest->clean_schema( $schema );
Drops all of the tables in the schema.
CDTest->populate_schema( $schema );
After you deploy your schema, you can use this method to populate the tables with test data.
CDTest->mass_populate_schema( $schema, $batches );
Populate the schema with massive amounts of data, mostly as duplicates of different rows.
The $batches are measured in thousands of artists. In other words, one batch is:
$batches
1000 artists ~2500 CDs ~20000 tracks
Just 10 batches takes up quite a bit of space (around 100MB of memory in the SQLite in-memory DB), and takes around 30 seconds to populate.
To install DBIx::OnlineDDL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::OnlineDDL
CPAN shell
perl -MCPAN -e shell install DBIx::OnlineDDL
For more information on module installation, please visit the detailed CPAN module installation guide.