-
Notifications
You must be signed in to change notification settings - Fork 215
/
configuration.t
72 lines (59 loc) · 2.21 KB
/
configuration.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/perl -w
use strict;
use warnings;
use Test::More tests => 17;
#use Test::More 'no_plan';
use File::Spec;
use Test::MockModule;
use Test::Exception;
use Test::NoWarnings;
my $CLASS;
BEGIN {
$CLASS = 'App::Sqitch::Config';
use_ok $CLASS or die;
}
isa_ok my $config = $CLASS->new, $CLASS, 'New config object';
is $config->confname, 'sqitch.conf', 'confname should be "sqitch.conf"';
SKIP: {
skip 'System dir can be modified at build time', 1
if $INC{'App/Sqitch/Config.pm'} =~ /\bblib\b/;
is $config->system_dir, File::Spec->catfile(
$Config::Config{prefix}, 'etc', 'sqitch'
), 'Default system directory should be correct';
}
is $config->user_dir, File::Spec->catfile(
File::HomeDir->my_home, '.sqitch'
), 'Default user directory should be correct';
is $config->global_file, File::Spec->catfile(
$config->system_dir, 'sqitch.conf'
), 'Default global file name should be correct';
my $file = File::Spec->catfile(qw(FOO BAR));
$ENV{SQITCH_SYSTEM_CONFIG} = $file;
is $config->global_file, $file,
'Should preferably get SQITCH_SYSTEM_CONFIG file from global_file';
is $config->system_file, $config->global_file, 'system_file should alias global_file';
is $config->user_file, File::Spec->catfile(
File::HomeDir->my_home, '.sqitch', 'sqitch.conf'
), 'Default user file name should be correct';
$ENV{SQITCH_USER_CONFIG} = $file,
is $config->user_file, $file,
'Should preferably get SQITCH_USER_CONFIG file from user_file';
is $config->local_file, 'sqitch.conf',
'Local file should be correct';
is $config->dir_file, $config->local_file, 'dir_file should alias local_file';
SQITCH_CONFIG: {
local $ENV{SQITCH_CONFIG} = 'sqitch.ini';
is $config->local_file, 'sqitch.ini', 'local_file should prefer $SQITCH_CONFIG';
is $config->dir_file, 'sqitch.ini', 'And so should dir_file';
}
chdir 't';
is_deeply $config->get_section(section => 'core'), {
engine => "pg",
extension => "ddl",
top_dir => "migrations",
uri => 'https://github.com/theory/sqitch/',
}, 'get_section("core") should work';
is_deeply $config->get_section(section => 'core.pg'), {
client => "/usr/local/pgsql/bin/psql",
username => "theory",
}, 'get_section("core.pg") should work';