The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test2::Tools::QuickDB - Quickly spin up temporary Database servers for tests.

DESCRIPTION

This is a test library build around DBIx::QuickDB.

SYNOPSIS

    use Test2::V0 -target => DBIx::QuickDB::Driver::PostgreSQL;
    use Test2::Tools::QuickDB;

    skipall_unless_can_db(driver => 'PostgreSQL');

    my $db = get_db(driver => 'PostgreSQL', load_sql => 't/schema/postgresql.sql'});

    ...

EXPORTS

$driver = skipall_unless_can_db('MyDriver')
$driver = skipall_unless_can_db(['MyDriver', 'OurDriver'])
$driver = skipall_unless_can_db(%spec)

This will look for a usable driver. If no usable driver is found, this will issue a skip_all to skip the current test or subtest. If at least one suable driver is found then the first one found will be returned.

If you pass in 1 argument it should either be a driver to try, or an arrayref of drivers to try.

If you passing multiple argument then you should follow the specifications in "SPEC HASH" in DBIx::QuickDB.

Feel free to ignore the return value.

$db = get_db
$db = get_db($name)
$db = get_db(\%spec)
$db = get_db($name, \%spec)
$db = get_db $name => \%spec

Get a database.

With no arguments it will give you an instance of the first working driver it finds.

You can provide a name for the db, the same instance can then be retrieved anywhere GLOBALLY using the same name.

You can provide a spec hashref which can contain any arguments documented in "SPEC HASH" in DBIx::QuickDB.

$db = get_db_or_skipall $name => \%spec
$db = get_db_or_skipall($name, \%spec)
$db = get_db_or_skipall($name)
$db = get_db_or_skipall(\%spec)

This combines get_db() and skipall_unless_can_db(). The arguments supported are identical to get_db().

SOURCE

The source code repository for DBIx-QuickDB can be found at https://github.com/exodist/DBIx-QuickDB/.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright 2020 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/