Giter Site home page Giter Site logo

app-prove-plugin-mysqlpool's Introduction

NAME

App::Prove::Plugin::MySQLPool - pool of Test::mysqld-s reused while testing

SYNOPSIS

prove -j4 -PMySQLPool t
  or
prove -j4 -PMySQLPool=MyApp::Test::DB t

DESCRIPTION

App::Prove::Plugin::MySQLPool is a prove plugin to speedup your tests using a pool of Test::mysqlds.

If you're using Test::mysqld, and have a lot of tests using it, annoyed by the mysql startup time slowing your tests, this module is for you.

This module launches -j number of Test::mysqld instances first.

Next, each mysqld instance optionally calls

MyApp::Test::DB->prepare( $mysqld );

You can CREATE TABLEs using GitDDL or DBIx::Class::Schema::Loader or others, or bulk insert master data before start testing.

MyApp::Test::DB only needs to implement a prepare sub. prepare is called only once per -j number of mysqld instances, and is called before your first .t file get tested.

# MyApp::Test::DB
sub prepare {
    my ($package, $mysqld) = @_;
    my $gd = GitDDL->new( dsn => $mysqld->dsn, ... );
    $gd->deploy;
}

Use $ENV{ PERL_TEST_MYSQLPOOL_DSN } like following in your test code.

my $dbh = DBI->connect( $ENV{ PERL_TEST_MYSQLPOOL_DSN } );

Since this module reuses mysqlds, you'd better erase all rows inserted at the top of your tests.

$dbh->do( "TRUNCATE $_" ) for @tables;

If you need customize my.cnf, you may want to implement my_cnf method in MyApp::Test::DB.

# MyApp::Test::DB
sub my_cnf {
    +{
        "skip-networking" => "",
        "character-set-server" => "utf8mb4",
    };
}

This config is used before launching Test::mysqld instances. So you can set non-dynamic system variables.

AUTHOR

Masakazu Ohtsuka [email protected]

SEE ALSO

prove, Test::mysqld

LICENSE

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.