nugrant 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +9 -9
- data/.gitignore +1 -0
- data/CHANGELOG.md +35 -2
- data/README.md +109 -2
- data/lib/nugrant/bag.rb +7 -3
- data/lib/nugrant/helper/bag.rb +12 -14
- data/lib/nugrant/helper/env.rb +232 -0
- data/lib/nugrant/vagrant/v1/command/env.rb +73 -0
- data/lib/nugrant/vagrant/v1/command/parameters.rb +13 -13
- data/lib/nugrant/vagrant/v1/command/root.rb +7 -2
- data/lib/nugrant/vagrant/v2/command/env.rb +73 -0
- data/lib/nugrant/vagrant/v2/command/parameters.rb +1 -1
- data/lib/nugrant/vagrant/v2/command/root.rb +7 -2
- data/lib/nugrant/version.rb +1 -1
- data/nugrant.gemspec +3 -2
- data/test/lib/nugrant/helper/test_env.rb +150 -0
- data/test/lib/nugrant/helper/test_stack.rb +2 -2
- data/test/lib/nugrant/test_bag.rb +7 -7
- data/test/lib/nugrant/test_config.rb +123 -120
- data/test/lib/nugrant/test_parameters.rb +199 -177
- data/test/resources/json/params_user_nil_values.json +9 -0
- data/test/resources/vagrantfiles/v2.defaults_null_values_in_vagrantuser +25 -0
- data/test/resources/yml/params_user_nil_values.yml +5 -0
- metadata +25 -51
@@ -1,125 +1,128 @@
|
|
1
|
-
require '
|
2
|
-
require 'test/unit'
|
1
|
+
require 'minitest/autorun'
|
3
2
|
require 'tmpdir'
|
4
3
|
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@default_param_filename = Nugrant::Config::DEFAULT_PARAMS_FILENAME
|
8
|
-
|
9
|
-
@old_working_dir = Dir.getwd()
|
10
|
-
@user_dir = Nugrant::Config.user_base_path()
|
11
|
-
@system_dir = Nugrant::Config.system_base_path()
|
12
|
-
|
13
|
-
Dir.chdir(Dir.tmpdir())
|
14
|
-
|
15
|
-
@project_dir = Dir.getwd()
|
16
|
-
end
|
17
|
-
|
18
|
-
def teardown
|
19
|
-
Dir.chdir(@old_working_dir)
|
20
|
-
|
21
|
-
@old_working_dir = nil
|
22
|
-
@project_dir = nil
|
23
|
-
@user_dir = nil
|
24
|
-
@system_dir = nil
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_default_values
|
28
|
-
config = Nugrant::Config.new
|
29
|
-
|
30
|
-
assert_equal(@default_param_filename, config.params_filename())
|
31
|
-
assert_equal("#{@project_dir}/#{@default_param_filename}", config.project_params_path())
|
32
|
-
assert_equal("#{@user_dir}/#{@default_param_filename}", config.user_params_path())
|
33
|
-
assert_equal("#{@system_dir}/#{@default_param_filename}", config.system_params_path())
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_custom_params_filename
|
37
|
-
config = Nugrant::Config.new({:params_filename => ".customparams"})
|
38
|
-
|
39
|
-
assert_equal(".customparams", config.params_filename())
|
40
|
-
assert_equal("#{@project_dir}/.customparams", config.project_params_path())
|
41
|
-
assert_equal("#{@user_dir}/.customparams", config.user_params_path())
|
42
|
-
assert_equal("#{@system_dir}/.customparams", config.system_params_path())
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_custom_params_filename_after_creation
|
46
|
-
config = Nugrant::Config.new({:params_filename => ".vagrantuser"})
|
47
|
-
|
48
|
-
config.params_filename = ".customparams"
|
49
|
-
|
50
|
-
assert_equal(".customparams", config.params_filename())
|
51
|
-
assert_equal("#{@project_dir}/.customparams", config.project_params_path())
|
52
|
-
assert_equal("#{@user_dir}/.customparams", config.user_params_path())
|
53
|
-
assert_equal("#{@system_dir}/.customparams", config.system_params_path())
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_custom_project_params_path
|
57
|
-
config = Nugrant::Config.new({
|
58
|
-
:params_filename => ".customparams",
|
59
|
-
:project_params_path => "#{@user_dir}/.projectcustomparams"
|
60
|
-
})
|
61
|
-
|
62
|
-
assert_equal(".customparams", config.params_filename())
|
63
|
-
assert_equal("#{@user_dir}/.projectcustomparams", config.project_params_path())
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_custom_user_params_path
|
67
|
-
config = Nugrant::Config.new({
|
68
|
-
:params_filename => ".customparams",
|
69
|
-
:user_params_path => "#{@system_dir}/.usercustomparams"
|
70
|
-
})
|
71
|
-
|
72
|
-
assert_equal(".customparams", config.params_filename())
|
73
|
-
assert_equal("#{@system_dir}/.usercustomparams", config.user_params_path()) end
|
74
|
-
|
75
|
-
def test_custom_system_params_path
|
76
|
-
config = Nugrant::Config.new({
|
77
|
-
:params_filename => ".customparams",
|
78
|
-
:system_params_path => "#{@project_dir}/.systemcustomparams"
|
79
|
-
})
|
80
|
-
|
81
|
-
assert_equal(".customparams", config.params_filename())
|
82
|
-
assert_equal("#{@project_dir}/.systemcustomparams", config.system_params_path())
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_custom_all
|
86
|
-
config = Nugrant::Config.new({
|
87
|
-
:params_filename => ".customparams",
|
88
|
-
:project_params_path => "#{@user_dir}/.projectcustomparams",
|
89
|
-
:user_params_path => "#{@system_dir}/.usercustomparams",
|
90
|
-
:system_params_path => "#{@project_dir}/.systemcustomparams"
|
91
|
-
})
|
92
|
-
|
93
|
-
assert_equal(".customparams", config.params_filename())
|
94
|
-
assert_equal("#{@user_dir}/.projectcustomparams", config.project_params_path())
|
95
|
-
assert_equal("#{@system_dir}/.usercustomparams", config.user_params_path())
|
96
|
-
assert_equal("#{@project_dir}/.systemcustomparams", config.system_params_path())
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_nil_project
|
100
|
-
config = Nugrant::Config.new({
|
101
|
-
:params_filename => ".customparams",
|
102
|
-
:project_params_path => nil,
|
103
|
-
})
|
104
|
-
|
105
|
-
assert_not_nil("#{@project_dir}/.customparams", config.project_params_path())
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_nil_user
|
109
|
-
config = Nugrant::Config.new({
|
110
|
-
:params_filename => ".customparams",
|
111
|
-
:user_params_path => nil,
|
112
|
-
})
|
113
|
-
|
114
|
-
assert_equal("#{@user_dir}/.customparams", config.user_params_path())
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_nil_system
|
118
|
-
config = Nugrant::Config.new({
|
119
|
-
:params_filename => ".customparams",
|
120
|
-
:system_params_path => nil,
|
121
|
-
})
|
4
|
+
require 'nugrant/config'
|
122
5
|
|
123
|
-
|
6
|
+
module Nugrant
|
7
|
+
class TestConfig < ::Minitest::Test
|
8
|
+
def setup
|
9
|
+
@default_param_filename = Nugrant::Config::DEFAULT_PARAMS_FILENAME
|
10
|
+
|
11
|
+
@old_working_dir = Dir.getwd()
|
12
|
+
@user_dir = Nugrant::Config.user_base_path()
|
13
|
+
@system_dir = Nugrant::Config.system_base_path()
|
14
|
+
|
15
|
+
Dir.chdir(Dir.tmpdir())
|
16
|
+
|
17
|
+
@project_dir = Dir.getwd()
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
Dir.chdir(@old_working_dir)
|
22
|
+
|
23
|
+
@old_working_dir = nil
|
24
|
+
@project_dir = nil
|
25
|
+
@user_dir = nil
|
26
|
+
@system_dir = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_default_values
|
30
|
+
config = Nugrant::Config.new
|
31
|
+
|
32
|
+
assert_equal(@default_param_filename, config.params_filename())
|
33
|
+
assert_equal("#{@project_dir}/#{@default_param_filename}", config.project_params_path())
|
34
|
+
assert_equal("#{@user_dir}/#{@default_param_filename}", config.user_params_path())
|
35
|
+
assert_equal("#{@system_dir}/#{@default_param_filename}", config.system_params_path())
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_custom_params_filename
|
39
|
+
config = Nugrant::Config.new({:params_filename => ".customparams"})
|
40
|
+
|
41
|
+
assert_equal(".customparams", config.params_filename())
|
42
|
+
assert_equal("#{@project_dir}/.customparams", config.project_params_path())
|
43
|
+
assert_equal("#{@user_dir}/.customparams", config.user_params_path())
|
44
|
+
assert_equal("#{@system_dir}/.customparams", config.system_params_path())
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_custom_params_filename_after_creation
|
48
|
+
config = Nugrant::Config.new({:params_filename => ".vagrantuser"})
|
49
|
+
|
50
|
+
config.params_filename = ".customparams"
|
51
|
+
|
52
|
+
assert_equal(".customparams", config.params_filename())
|
53
|
+
assert_equal("#{@project_dir}/.customparams", config.project_params_path())
|
54
|
+
assert_equal("#{@user_dir}/.customparams", config.user_params_path())
|
55
|
+
assert_equal("#{@system_dir}/.customparams", config.system_params_path())
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_custom_project_params_path
|
59
|
+
config = Nugrant::Config.new({
|
60
|
+
:params_filename => ".customparams",
|
61
|
+
:project_params_path => "#{@user_dir}/.projectcustomparams"
|
62
|
+
})
|
63
|
+
|
64
|
+
assert_equal(".customparams", config.params_filename())
|
65
|
+
assert_equal("#{@user_dir}/.projectcustomparams", config.project_params_path())
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_custom_user_params_path
|
69
|
+
config = Nugrant::Config.new({
|
70
|
+
:params_filename => ".customparams",
|
71
|
+
:user_params_path => "#{@system_dir}/.usercustomparams"
|
72
|
+
})
|
73
|
+
|
74
|
+
assert_equal(".customparams", config.params_filename())
|
75
|
+
assert_equal("#{@system_dir}/.usercustomparams", config.user_params_path()) end
|
76
|
+
|
77
|
+
def test_custom_system_params_path
|
78
|
+
config = Nugrant::Config.new({
|
79
|
+
:params_filename => ".customparams",
|
80
|
+
:system_params_path => "#{@project_dir}/.systemcustomparams"
|
81
|
+
})
|
82
|
+
|
83
|
+
assert_equal(".customparams", config.params_filename())
|
84
|
+
assert_equal("#{@project_dir}/.systemcustomparams", config.system_params_path())
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_custom_all
|
88
|
+
config = Nugrant::Config.new({
|
89
|
+
:params_filename => ".customparams",
|
90
|
+
:project_params_path => "#{@user_dir}/.projectcustomparams",
|
91
|
+
:user_params_path => "#{@system_dir}/.usercustomparams",
|
92
|
+
:system_params_path => "#{@project_dir}/.systemcustomparams"
|
93
|
+
})
|
94
|
+
|
95
|
+
assert_equal(".customparams", config.params_filename())
|
96
|
+
assert_equal("#{@user_dir}/.projectcustomparams", config.project_params_path())
|
97
|
+
assert_equal("#{@system_dir}/.usercustomparams", config.user_params_path())
|
98
|
+
assert_equal("#{@project_dir}/.systemcustomparams", config.system_params_path())
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_nil_project
|
102
|
+
config = Nugrant::Config.new({
|
103
|
+
:params_filename => ".customparams",
|
104
|
+
:project_params_path => nil,
|
105
|
+
})
|
106
|
+
|
107
|
+
assert_equal("#{@project_dir}/.customparams", config.project_params_path())
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_nil_user
|
111
|
+
config = Nugrant::Config.new({
|
112
|
+
:params_filename => ".customparams",
|
113
|
+
:user_params_path => nil,
|
114
|
+
})
|
115
|
+
|
116
|
+
assert_equal("#{@user_dir}/.customparams", config.user_params_path())
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_nil_system
|
120
|
+
config = Nugrant::Config.new({
|
121
|
+
:params_filename => ".customparams",
|
122
|
+
:system_params_path => nil,
|
123
|
+
})
|
124
|
+
|
125
|
+
assert_equal("#{@system_dir}/.customparams", config.system_params_path())
|
126
|
+
end
|
124
127
|
end
|
125
128
|
end
|
@@ -1,235 +1,257 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
1
3
|
require 'nugrant'
|
2
4
|
require 'nugrant/parameters'
|
3
|
-
require 'test/unit'
|
4
|
-
|
5
|
-
class Nugrant::TestParameters < Test::Unit::TestCase
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
module Nugrant
|
7
|
+
class TestParameters < ::Minitest::Test
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
@@PARAMS_FILETYPES = [:json, :yml]
|
10
|
+
@@INVALID_PATH = "impossible_file_path.yml.impossible"
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
system_params_path = "#{resource_path}/#{system_params_filename}.#{params_filetype}" if system_params_filename
|
12
|
+
def create_parameters(params_filetype, project_params_filename, user_params_filename, system_params_filename)
|
13
|
+
resource_path = File.expand_path("#{File.dirname(__FILE__)}/../../resources/#{params_filetype.to_s()}")
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
:user_params_path => user_params_path,
|
21
|
-
:system_params_path => system_params_path
|
22
|
-
})
|
23
|
-
end
|
15
|
+
project_params_path = "#{resource_path}/#{project_params_filename}.#{params_filetype}" if project_params_filename
|
16
|
+
user_params_path = "#{resource_path}/#{user_params_filename}.#{params_filetype}" if user_params_filename
|
17
|
+
system_params_path = "#{resource_path}/#{system_params_filename}.#{params_filetype}" if system_params_filename
|
24
18
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
19
|
+
return Nugrant::create_parameters({
|
20
|
+
:params_filetype => params_filetype,
|
21
|
+
:project_params_path => project_params_path,
|
22
|
+
:user_params_path => user_params_path,
|
23
|
+
:system_params_path => system_params_path
|
24
|
+
})
|
25
|
+
end
|
30
26
|
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
def assert_all_access_equal(value, parameters, key)
|
28
|
+
assert_equal(value, parameters.method_missing(key.to_sym), "parameters.#{key.to_sym.inspect}")
|
29
|
+
assert_equal(value, parameters[key.to_s], "parameters[#{key.to_s.inspect}]")
|
30
|
+
assert_equal(value, parameters[key.to_sym], "parameters[#{key.to_sym.inspect}]")
|
34
31
|
end
|
35
32
|
|
36
|
-
|
37
|
-
|
33
|
+
def assert_level(parameters, results)
|
34
|
+
results.each do |key, value|
|
35
|
+
assert_all_access_equal(value, parameters, key)
|
36
|
+
end
|
38
37
|
|
39
|
-
|
40
|
-
assert_raise(KeyError) do
|
41
|
-
parameters[key]
|
38
|
+
assert_key_error(parameters, "0.0.0")
|
42
39
|
end
|
43
|
-
end
|
44
40
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
assert_level(parameters, {
|
50
|
-
"1.1.1" => "project",
|
51
|
-
"1.1.0" => "project",
|
52
|
-
"1.0.1" => "project",
|
53
|
-
"0.1.1" => "user",
|
54
|
-
"1.0.0" => "project",
|
55
|
-
"0.1.0" => "user",
|
56
|
-
"0.0.1" => "system",
|
57
|
-
})
|
41
|
+
def assert_key_error(parameters, key)
|
42
|
+
assert_raises(KeyError) do
|
43
|
+
parameters[key]
|
44
|
+
end
|
58
45
|
end
|
59
|
-
end
|
60
46
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
47
|
+
def test_params_level_1()
|
48
|
+
filetypes.each do |params_filetype|
|
49
|
+
parameters = create_parameters(params_filetype, "params_project_1", "params_user_1", "params_system_1")
|
50
|
+
|
51
|
+
assert_level(parameters, {
|
52
|
+
"1.1.1" => "project",
|
53
|
+
"1.1.0" => "project",
|
54
|
+
"1.0.1" => "project",
|
55
|
+
"0.1.1" => "user",
|
56
|
+
"1.0.0" => "project",
|
57
|
+
"0.1.0" => "user",
|
58
|
+
"0.0.1" => "system",
|
59
|
+
})
|
60
|
+
end
|
61
|
+
end
|
74
62
|
|
75
|
-
|
76
|
-
|
77
|
-
"
|
78
|
-
|
79
|
-
"
|
80
|
-
|
81
|
-
|
82
|
-
|
63
|
+
def test_params_level_2()
|
64
|
+
filetypes.each do |params_filetype|
|
65
|
+
parameters = create_parameters(params_filetype, "params_project_2", "params_user_2", "params_system_2")
|
66
|
+
|
67
|
+
run_second_level(parameters, "1.1.1", {
|
68
|
+
"1.1.1" => "project",
|
69
|
+
"1.1.0" => "project",
|
70
|
+
"1.0.1" => "project",
|
71
|
+
"0.1.1" => "user",
|
72
|
+
"1.0.0" => "project",
|
73
|
+
"0.1.0" => "user",
|
74
|
+
"0.0.1" => "system",
|
75
|
+
})
|
76
|
+
|
77
|
+
run_second_level(parameters, "1.1.0", {
|
78
|
+
"1.1.1" => "project",
|
79
|
+
"1.1.0" => "project",
|
80
|
+
"1.0.1" => "project",
|
81
|
+
"0.1.1" => "user",
|
82
|
+
"1.0.0" => "project",
|
83
|
+
"0.1.0" => "user",
|
84
|
+
})
|
85
|
+
|
86
|
+
run_second_level(parameters, "1.0.1", {
|
87
|
+
"1.1.1" => "project",
|
88
|
+
"1.1.0" => "project",
|
89
|
+
"1.0.1" => "project",
|
90
|
+
"0.1.1" => "system",
|
91
|
+
"1.0.0" => "project",
|
92
|
+
"0.0.1" => "system",
|
93
|
+
})
|
94
|
+
|
95
|
+
run_second_level(parameters, "0.1.1", {
|
96
|
+
"1.1.1" => "user",
|
97
|
+
"1.1.0" => "user",
|
98
|
+
"1.0.1" => "system",
|
99
|
+
"0.1.1" => "user",
|
100
|
+
"0.1.0" => "user",
|
101
|
+
"0.0.1" => "system",
|
102
|
+
})
|
103
|
+
|
104
|
+
run_second_level(parameters, "1.0.0", {
|
105
|
+
"1.1.1" => "project",
|
106
|
+
"1.1.0" => "project",
|
107
|
+
"1.0.1" => "project",
|
108
|
+
"1.0.0" => "project",
|
109
|
+
})
|
110
|
+
|
111
|
+
run_second_level(parameters, "0.1.0", {
|
112
|
+
"1.1.1" => "user",
|
113
|
+
"1.1.0" => "user",
|
114
|
+
"0.1.1" => "user",
|
115
|
+
"0.1.0" => "user",
|
116
|
+
})
|
117
|
+
|
118
|
+
run_second_level(parameters, "0.0.1", {
|
119
|
+
"1.1.1" => "system",
|
120
|
+
"1.0.1" => "system",
|
121
|
+
"0.1.1" => "system",
|
122
|
+
"0.0.1" => "system",
|
123
|
+
})
|
124
|
+
|
125
|
+
assert_key_error(parameters, "0.0.0")
|
126
|
+
end
|
127
|
+
end
|
83
128
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
"1.0.1" => "project",
|
88
|
-
"0.1.1" => "system",
|
89
|
-
"1.0.0" => "project",
|
90
|
-
"0.0.1" => "system",
|
91
|
-
})
|
129
|
+
def run_second_level(parameters, key, results)
|
130
|
+
assert_level(parameters.send(key), results)
|
131
|
+
assert_level(parameters[key], results)
|
92
132
|
|
93
|
-
|
94
|
-
|
95
|
-
"1.1.0" => "user",
|
96
|
-
"1.0.1" => "system",
|
97
|
-
"0.1.1" => "user",
|
98
|
-
"0.1.0" => "user",
|
99
|
-
"0.0.1" => "system",
|
100
|
-
})
|
133
|
+
assert_key_error(parameters, "0.0.0")
|
134
|
+
end
|
101
135
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
"1.0.0" => "project",
|
107
|
-
})
|
136
|
+
def test_params_array()
|
137
|
+
file_path = "params_array"
|
138
|
+
filetypes.each do |params_filetype|
|
139
|
+
parameters = create_parameters(params_filetype, file_path, invalid_path, invalid_path)
|
108
140
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
"0.1.1" => "user",
|
113
|
-
"0.1.0" => "user",
|
114
|
-
})
|
141
|
+
assert_equal(["1", "2", "3"], parameters['level1']['level2'])
|
142
|
+
end
|
143
|
+
end
|
115
144
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
"0.1.1" => "system",
|
120
|
-
"0.0.1" => "system",
|
121
|
-
})
|
145
|
+
def test_file_nil()
|
146
|
+
run_test_file_invalid(nil)
|
147
|
+
end
|
122
148
|
|
123
|
-
|
149
|
+
def test_file_does_not_exist()
|
150
|
+
run_test_file_invalid("impossible_file_path.yml.impossible")
|
124
151
|
end
|
125
|
-
end
|
126
152
|
|
127
|
-
|
128
|
-
|
129
|
-
|
153
|
+
def run_test_file_invalid(invalid_value)
|
154
|
+
filetypes.each do |params_filetype|
|
155
|
+
parameters = create_parameters(params_filetype, "params_simple", invalid_path, invalid_path)
|
156
|
+
assert_all_access_equal("value", parameters, "test")
|
130
157
|
|
131
|
-
|
132
|
-
|
158
|
+
parameters = create_parameters(params_filetype, invalid_path, "params_simple", invalid_path)
|
159
|
+
assert_all_access_equal("value", parameters, "test")
|
133
160
|
|
134
|
-
|
135
|
-
|
136
|
-
filetypes.each do |params_filetype|
|
137
|
-
parameters = create_parameters(params_filetype, file_path, invalid_path, invalid_path)
|
161
|
+
parameters = create_parameters(params_filetype, invalid_path, invalid_path, "params_simple")
|
162
|
+
assert_all_access_equal("value", parameters, "test")
|
138
163
|
|
139
|
-
|
164
|
+
parameters = create_parameters(params_filetype, invalid_path, invalid_path, invalid_path)
|
165
|
+
assert(parameters)
|
166
|
+
end
|
140
167
|
end
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_file_nil()
|
144
|
-
run_test_file_invalid(nil)
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_file_does_not_exist()
|
148
|
-
run_test_file_invalid("impossible_file_path.yml.impossible")
|
149
|
-
end
|
150
168
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
assert_all_access_equal("value", parameters, "test")
|
169
|
+
def test_params_windows_eol()
|
170
|
+
run_test_params_eol("params_windows_eol")
|
171
|
+
end
|
155
172
|
|
156
|
-
|
157
|
-
|
173
|
+
def test_params_unix_eol()
|
174
|
+
run_test_params_eol("params_unix_eol")
|
175
|
+
end
|
158
176
|
|
159
|
-
|
160
|
-
|
177
|
+
def run_test_params_eol(file_path)
|
178
|
+
filetypes.each do |params_filetype|
|
179
|
+
parameters = create_parameters(params_filetype, file_path, invalid_path, invalid_path)
|
161
180
|
|
162
|
-
|
163
|
-
|
181
|
+
assert_all_access_equal("value1", parameters, 'level1')
|
182
|
+
assert_all_access_equal("value2", parameters['level2'], 'first')
|
183
|
+
end
|
164
184
|
end
|
165
|
-
end
|
166
185
|
|
167
|
-
|
168
|
-
|
169
|
-
|
186
|
+
def test_restricted_defaults_usage()
|
187
|
+
filetypes.each do |params_filetype|
|
188
|
+
parameters = create_parameters(params_filetype, "params_defaults_at_root", invalid_path, invalid_path)
|
170
189
|
|
171
|
-
|
172
|
-
|
173
|
-
end
|
190
|
+
assert_all_access_equal("value", parameters, :defaults)
|
191
|
+
end
|
174
192
|
|
175
|
-
|
176
|
-
|
177
|
-
parameters = create_parameters(params_filetype, file_path, invalid_path, invalid_path)
|
193
|
+
filetypes.each do |params_filetype|
|
194
|
+
parameters = create_parameters(params_filetype, "params_defaults_not_at_root", invalid_path, invalid_path)
|
178
195
|
|
179
|
-
|
180
|
-
|
196
|
+
assert_all_access_equal("value", parameters.level, :defaults)
|
197
|
+
end
|
181
198
|
end
|
182
|
-
end
|
183
199
|
|
184
|
-
|
185
|
-
|
186
|
-
|
200
|
+
def test_defaults()
|
201
|
+
filetypes.each do |params_filetype|
|
202
|
+
parameters = create_parameters(params_filetype, "params_simple", invalid_path, invalid_path)
|
203
|
+
parameters.defaults = {"test" => "override1", "level" => "new1"}
|
187
204
|
|
188
|
-
|
205
|
+
assert_all_access_equal("value", parameters, 'test')
|
206
|
+
assert_all_access_equal("new1", parameters, 'level')
|
207
|
+
end
|
189
208
|
end
|
190
209
|
|
191
|
-
|
192
|
-
|
210
|
+
def test_empty_file()
|
211
|
+
filetypes.each do |params_filetype|
|
212
|
+
parameters = create_parameters(params_filetype, "params_empty", invalid_path, invalid_path)
|
213
|
+
parameters.defaults = {"test" => "value"}
|
193
214
|
|
194
|
-
|
215
|
+
assert_all_access_equal("value", parameters, 'test')
|
216
|
+
end
|
195
217
|
end
|
196
|
-
end
|
197
218
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
219
|
+
def test_file_not_hash()
|
220
|
+
["boolean", "list"].each do |wrong_type|
|
221
|
+
filetypes.each do |params_filetype|
|
222
|
+
parameters = create_parameters(params_filetype, "params_#{wrong_type}", invalid_path, invalid_path)
|
223
|
+
parameters.defaults = {"test" => "value"}
|
202
224
|
|
203
|
-
|
204
|
-
|
225
|
+
assert_all_access_equal("value", parameters, 'test')
|
226
|
+
end
|
227
|
+
end
|
205
228
|
end
|
206
|
-
end
|
207
229
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
230
|
+
def test_nil_values()
|
231
|
+
filetypes.each do |params_filetype|
|
232
|
+
parameters = create_parameters(params_filetype, "params_user_nil_values", invalid_path, invalid_path)
|
233
|
+
parameters.defaults = {:nil => "Not nil", :deep => {:nil => "Not nil", :deeper => {:nil => "Not nil"}}}
|
212
234
|
|
213
|
-
|
214
|
-
|
215
|
-
|
235
|
+
assert_all_access_equal("Not nil", parameters[:deep][:deeper], :nil)
|
236
|
+
assert_all_access_equal("Not nil", parameters[:deep], :nil)
|
237
|
+
assert_all_access_equal("Not nil", parameters, :nil)
|
238
|
+
end
|
216
239
|
|
217
|
-
def test_file_not_hash()
|
218
|
-
["boolean", "list"].each do |wrong_type|
|
219
240
|
filetypes.each do |params_filetype|
|
220
|
-
parameters = create_parameters(params_filetype, "
|
221
|
-
parameters.defaults = {"test" => "value"}
|
241
|
+
parameters = create_parameters(params_filetype, "params_user_nil_values", invalid_path, invalid_path)
|
222
242
|
|
223
|
-
assert_all_access_equal(
|
243
|
+
assert_all_access_equal(nil, parameters[:deep][:deeper], :nil)
|
244
|
+
assert_all_access_equal(nil, parameters[:deep], :nil)
|
245
|
+
assert_all_access_equal(nil, parameters, :nil)
|
224
246
|
end
|
225
247
|
end
|
226
|
-
end
|
227
248
|
|
228
|
-
|
229
|
-
|
230
|
-
|
249
|
+
def filetypes()
|
250
|
+
@@PARAMS_FILETYPES
|
251
|
+
end
|
231
252
|
|
232
|
-
|
233
|
-
|
253
|
+
def invalid_path()
|
254
|
+
@@INVALID_PATH
|
255
|
+
end
|
234
256
|
end
|
235
257
|
end
|