4
# Copyright (c) 2007 MySQL AB, 2009 Sun Microsystems, Inc.
5
# Use is subject to license terms.
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; version 2 of the License.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
use File::Temp qw / tempdir /;
24
my $dir = tempdir( CLEANUP => 1 );
26
use Test::More qw(no_plan);
28
BEGIN { use_ok ( "My::ConfigFactory" ) };
30
my $gen1_cnf= "$dir/gen1.cnf";
31
open(OUT, ">", $gen1_cnf) or die;
45
MASTER_MY_PORT=\@mysqld.master.port
53
my $config= My::ConfigFactory->new_config
57
template_path => $gen1_cnf,
58
vardir => "/path/to/var",
60
#hosts => [ 'host1', 'host2' ],
66
ok ( $config->group("mysqld.master"), "group mysqld.master exists");
67
ok ( $config->group("mysqld.1"), "group mysqld.1 exists");
68
ok ( $config->group("client"), "group client exists");
69
ok ( !$config->group("mysqld.3"), "group mysqld.3 does not exist");
71
ok ( $config->first_like("mysqld"), "group like 'mysqld' exists");
73
is( $config->value('mysqld.1', '#host'), 'localhost',
74
"mysqld.1.#host has been generated");
76
is( $config->value('client', 'host'), 'localhost',
77
"client.host has been generated");
79
is( $config->value('client', 'host'),
80
$config->value('mysqld.master', '#host'),
81
"client.host is same as mysqld.master.host");
83
ok ( $config->value("mysqld.1", 'character-sets-dir') =~ /$basedir.*charsets$/,
84
"'character-sets-dir' generated");
86
ok ( $config->value("mysqld.1", 'lc-messages-dir') =~ /$basedir.*share$/,
87
"'lc-messages-dir' generated");
89
ok ( $config->value("ENV", 'MASTER_MY_PORT') =~ /\d/,
90
"'lc-messages-dir' generated");
92
my $gen2_cnf= "$dir/gen2.cnf";
93
open(OUT, ">", $gen2_cnf) or die;
101
my $config2= My::ConfigFactory->new_config
105
template_path => $gen2_cnf,
106
vardir => "/path/to/var",
108
#hosts => [ 'host1', 'host2' ],
114
ok ( $config2->first_like("mysqld"), "group like 'mysqld' exists");