Tripletail
view release on metacpan or search on metacpan
t/db-mysql-readdefaultfile.t view on Meta::CPAN
## ----------------------------------------------------------------------------
# t/db-mysql-readdefaultfile.t
# -----------------------------------------------------------------------------
# programmed by Haruka Kataoka, archinet inc.
# (modified from db-mysql.t)
# -----------------------------------------------------------------------------
# (db-mysql.t)
# Mastering programmed by YAMASHINA Hio
#
# Copyright YMIRLINK, Inc.
# -----------------------------------------------------------------------------
# $Id: db-mysql-readdefaultfile.t,v 1.1 2009/07/17 02:51:07 Kataoka Exp Kataoka $
# -----------------------------------------------------------------------------
use strict;
use warnings;
use Test::More;
use Test::Exception;
use Data::Dumper;
use File::Spec;
our %DBINFO;
our $configfile;
BEGIN{
$configfile = File::Spec->rel2abs("tmp$$.cnf");
%DBINFO = (
dbname => $ENV{MYSQL_DBNAME} || 'test',
mysql_read_default_file => $configfile,
mysql_read_default_group => 'tripletail',
);
};
sub createTestConfigFile {
my %config = (
user => $ENV{MYSQL_USER} || '',
password => $ENV{MYSQL_PASS} || '',
host => shift,
'default-character-set' => shift,
);
open my $fh, '>', $configfile;
print $fh <<EndOfConf;
[client]
user = "$config{'user'}"
password = "$config{'password'}"
host = "$config{'host'}"
[tripletail]
default-character-set = "$config{'default-character-set'}"
EndOfConf
close $fh;
}
END{
unlink $configfile if -e $configfile;
};
use lib '.';
use t::make_ini {
ini => {
TL => {
trap => 'none',
},
DB => {
type => 'mysql',
defaultset => 'DBSET_test',
DBSET_test => [qw(DBCONN_test)]
},
DBCONN_test => \%DBINFO,
},
};
use Tripletail $t::make_ini::INI_FILE;
my $has_DBD_mysql = eval 'use DBD::mysql;1';
if( !$has_DBD_mysql )
{
plan skip_all => "no DBD::mysql";
}
my $mysql_version = _mysql_version();
if( !$mysql_version )
{
plan skip_all => "mysql version check failed";
}
if( $mysql_version < 5.001 )
{
plan skip_all => "mysql 5.1.x is required, got $mysql_version";
( run in 0.703 second using v1.01-cache-2.11-cpan-13bb782fe5a )