DBIx-Class-Storage-DBI-MariaDB

 view release on metacpan or  search on metacpan

t/01-operations.t  view on Meta::CPAN

# tests inpsired/copied from https://github.com/Perl5/DBIx-Class/blob/maint/0.0828xx/t/71mysql.t

use strict;
use warnings;

use Test::More;
use Test::Exception;
use Test::Warn;

use Scalar::Util qw/weaken/;

use lib qw(t/lib);
use MyApp::Schema;

my ( $dsn, $user, $pass ) =
  @ENV{ map { "DBICTEST_MARIADB_${_}" } qw/DSN USER PASS/ };

plan skip_all => 'Set $ENV{DBICTEST_MARIADB_DSN}, _USER and _PASS to run tests'
  unless ( $dsn && $user );

t/01-operations.t  view on Meta::CPAN

    local $ENV{MOD_PERL} = 'whyisperllikethis';
    my $schema = MyApp::Schema->connect( $dsn, $user, $pass );
    ok(
        !$schema->storage->_get_dbh->{mariadb_auto_reconnect},
        'mariadb_auto_reconnect unset regardless of ENV'
    );

    my $schema_autorecon = MyApp::Schema->connect( $dsn, $user, $pass,
        { mariadb_auto_reconnect => 1 } );
    my $orig_dbh = $schema_autorecon->storage->_get_dbh;
    weaken $orig_dbh;

    ok( $orig_dbh, 'Got weak $dbh ref' );
    ok( $orig_dbh->{mariadb_auto_reconnect},
        'mariadb_auto_reconnect is properly set if explicitly requested' );

    my $rs = $schema_autorecon->resultset('Artist');

    # kill our $dbh
    $schema_autorecon->storage->_dbh(undef);
    ok( !defined $orig_dbh, '$dbh handle is gone' );



( run in 0.272 second using v1.01-cache-2.11-cpan-65fba6d93b7 )