nugrant 1.4.2 → 2.0.0.dev1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +1 -2
- data/.travis.yml +0 -6
- data/CHANGELOG.md +3 -79
- data/Gemfile +8 -8
- data/README.md +10 -146
- data/lib/nugrant.rb +4 -19
- data/lib/nugrant/bag.rb +8 -12
- data/lib/nugrant/config.rb +55 -24
- data/lib/nugrant/helper/bag.rb +19 -17
- data/lib/nugrant/parameters.rb +37 -9
- data/lib/nugrant/vagrant/v1/command/parameters.rb +13 -13
- data/lib/nugrant/vagrant/v1/command/root.rb +2 -7
- data/lib/nugrant/vagrant/v1/config/user.rb +1 -10
- data/lib/nugrant/vagrant/v2/command/parameters.rb +1 -1
- data/lib/nugrant/vagrant/v2/command/root.rb +2 -7
- data/lib/nugrant/vagrant/v2/config/user.rb +1 -10
- data/lib/nugrant/version.rb +1 -1
- data/nugrant.gemspec +1 -4
- data/test/lib/nugrant/test_bag.rb +19 -33
- data/test/lib/nugrant/test_config.rb +92 -100
- data/test/lib/nugrant/test_parameters.rb +186 -203
- data/test/resources/README.md +11 -11
- data/test/resources/{vagrantfiles/v1.empty → Vagrantfile.v1.empty} +0 -0
- data/test/resources/{vagrantfiles/v1.fake → Vagrantfile.v1.fake} +0 -0
- data/test/resources/{vagrantfiles/v1.real → Vagrantfile.v1.real} +0 -0
- data/test/resources/{vagrantfiles/v2.empty → Vagrantfile.v2.empty} +0 -0
- data/test/resources/{vagrantfiles/v2.fake → Vagrantfile.v2.fake} +1 -4
- data/test/resources/{vagrantfiles/v2.real → Vagrantfile.v2.real} +0 -0
- data/test/resources/json/params_current_1.json +6 -0
- data/test/resources/json/params_current_2.json +29 -0
- data/test/resources/{yml → yaml}/params_array.yml +0 -0
- data/test/resources/{yml → yaml}/params_boolean.yml +0 -0
- data/test/resources/{yml → yaml}/params_combinations.yml +0 -0
- data/test/resources/yaml/params_current_1.yml +4 -0
- data/test/resources/yaml/params_current_2.yml +23 -0
- data/test/resources/{yml → yaml}/params_defaults_at_root.yml +0 -0
- data/test/resources/{yml → yaml}/params_defaults_not_at_root.yml +0 -0
- data/test/resources/{yml → yaml}/params_empty.yml +0 -0
- data/test/resources/{yml → yaml}/params_list.yml +0 -0
- data/test/resources/{yml → yaml}/params_simple.yml +0 -0
- data/test/resources/{yml → yaml}/params_system_1.yml +0 -0
- data/test/resources/{yml → yaml}/params_system_2.yml +0 -0
- data/test/resources/{yml → yaml}/params_unix_eol.yml +0 -0
- data/test/resources/{yml → yaml}/params_user_1.yml +0 -0
- data/test/resources/{yml → yaml}/params_user_2.yml +0 -0
- data/test/resources/{yml → yaml}/params_windows_eol.yml +0 -0
- metadata +71 -95
- data/lib/nugrant/helper/env/exporter.rb +0 -208
- data/lib/nugrant/helper/env/namer.rb +0 -47
- data/lib/nugrant/helper/stack.rb +0 -86
- data/lib/nugrant/vagrant/errors.rb +0 -27
- data/lib/nugrant/vagrant/v1/command/env.rb +0 -107
- data/lib/nugrant/vagrant/v2/command/env.rb +0 -107
- data/locales/en.yml +0 -13
- data/test/lib/nugrant/helper/env/test_exporter.rb +0 -238
- data/test/lib/nugrant/helper/test_stack.rb +0 -149
- data/test/resources/json/params_project_1.json +0 -6
- data/test/resources/json/params_project_2.json +0 -29
- data/test/resources/json/params_user_nil_values.json +0 -9
- data/test/resources/vagrantfiles/v1.defaults_mixed_string_symbols +0 -18
- data/test/resources/vagrantfiles/v1.defaults_using_string +0 -18
- data/test/resources/vagrantfiles/v1.defaults_using_symbol +0 -18
- data/test/resources/vagrantfiles/v1.missing_parameter +0 -3
- data/test/resources/vagrantfiles/v2.defaults_mixed_string_symbols +0 -20
- data/test/resources/vagrantfiles/v2.defaults_null_values_in_vagrantuser +0 -25
- data/test/resources/vagrantfiles/v2.defaults_using_string +0 -20
- data/test/resources/vagrantfiles/v2.defaults_using_symbol +0 -20
- data/test/resources/vagrantfiles/v2.missing_parameter +0 -5
- data/test/resources/yml/params_project_1.yml +0 -4
- data/test/resources/yml/params_project_2.yml +0 -23
- data/test/resources/yml/params_user_nil_values.yml +0 -5
data/lib/nugrant/version.rb
CHANGED
data/nugrant.gemspec
CHANGED
@@ -25,11 +25,8 @@ Gem::Specification.new do |gem|
|
|
25
25
|
|
26
26
|
gem.files = `git ls-files`.split($/)
|
27
27
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
28
|
-
gem.test_files = gem.files.grep(%r{^(test
|
28
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
29
29
|
gem.require_paths = ["lib"]
|
30
30
|
|
31
|
-
gem.add_dependency "multi_json", "~> 1.8"
|
32
|
-
|
33
31
|
gem.add_development_dependency "rake"
|
34
|
-
gem.add_development_dependency "minitest", "~> 5.0.8"
|
35
32
|
end
|
@@ -1,23 +1,11 @@
|
|
1
|
-
require '
|
1
|
+
require 'test/unit'
|
2
2
|
|
3
3
|
require 'nugrant/bag'
|
4
4
|
|
5
5
|
module Nugrant
|
6
|
-
class TestBag < ::
|
7
|
-
def create_bag(
|
8
|
-
return Bag.new(
|
9
|
-
end
|
10
|
-
|
11
|
-
def assert_all_access_equal(value, bag, key)
|
12
|
-
assert_equal(value, bag.method_missing(key.to_sym), "bag.#{key.to_sym.inspect}")
|
13
|
-
assert_equal(value, bag[key.to_s], "bag[#{key.to_s.inspect}]")
|
14
|
-
assert_equal(value, bag[key.to_sym], "bag[#{key.to_sym.inspect}]")
|
15
|
-
end
|
16
|
-
|
17
|
-
def assert_all_access_bag(value, bag, key)
|
18
|
-
assert_bag(value, bag.method_missing(key.to_sym))
|
19
|
-
assert_bag(value, bag[key.to_s])
|
20
|
-
assert_bag(value, bag[key.to_sym])
|
6
|
+
class TestBag < Test::Unit::TestCase
|
7
|
+
def create_bag(parameters)
|
8
|
+
return Bag.new(parameters)
|
21
9
|
end
|
22
10
|
|
23
11
|
def assert_bag(parameters, bag)
|
@@ -25,11 +13,13 @@ module Nugrant
|
|
25
13
|
|
26
14
|
parameters.each do |key, value|
|
27
15
|
if not value.kind_of?(Hash)
|
28
|
-
|
16
|
+
assert_equal(value, bag.send(key))
|
17
|
+
assert_equal(value, bag[key])
|
29
18
|
next
|
30
19
|
end
|
31
20
|
|
32
|
-
|
21
|
+
assert_bag(value, bag.send(key))
|
22
|
+
assert_bag(value, bag[key])
|
33
23
|
end
|
34
24
|
end
|
35
25
|
|
@@ -84,17 +74,13 @@ module Nugrant
|
|
84
74
|
def test_undefined_value()
|
85
75
|
bag = create_bag({"value" => "one"})
|
86
76
|
|
87
|
-
|
77
|
+
assert_raise(KeyError) do
|
88
78
|
bag.invalid_value
|
89
79
|
end
|
90
80
|
|
91
|
-
|
81
|
+
assert_raise(KeyError) do
|
92
82
|
bag["invalid_value"]
|
93
83
|
end
|
94
|
-
|
95
|
-
assert_raises(KeyError) do
|
96
|
-
bag[:invalid_value]
|
97
|
-
end
|
98
84
|
end
|
99
85
|
|
100
86
|
def test_to_hash()
|
@@ -103,29 +89,29 @@ module Nugrant
|
|
103
89
|
assert_kind_of(Hash, hash)
|
104
90
|
assert_equal({}, hash)
|
105
91
|
|
106
|
-
hash = create_bag({"value" => {
|
92
|
+
hash = create_bag({"value" => {"one" => "value", "two" => "value"}}).__to_hash()
|
107
93
|
|
108
94
|
assert_kind_of(Hash, hash)
|
109
|
-
assert_kind_of(Hash, hash[
|
110
|
-
assert_kind_of(String, hash[
|
111
|
-
assert_kind_of(String, hash[
|
112
|
-
assert_equal({
|
95
|
+
assert_kind_of(Hash, hash['value'])
|
96
|
+
assert_kind_of(String, hash['value']['one'])
|
97
|
+
assert_kind_of(String, hash['value']['two'])
|
98
|
+
assert_equal({"value" => {"one" => "value", "two" => "value"}}, hash)
|
113
99
|
end
|
114
100
|
|
115
101
|
def test_merge_array()
|
116
102
|
bag1 = create_bag({"first" => [1, 2]})
|
117
|
-
bag2 = create_bag({
|
103
|
+
bag2 = create_bag({"first" => [2, 3]})
|
118
104
|
|
119
105
|
bag1.__merge!(bag2);
|
120
106
|
|
121
|
-
assert_equal({
|
107
|
+
assert_equal({"first" => [1, 2, 3]}, bag1.__to_hash())
|
122
108
|
|
123
109
|
bag1 = create_bag({"first" => [1, 2]})
|
124
|
-
bag2 = create_bag({
|
110
|
+
bag2 = create_bag({"first" => "string"})
|
125
111
|
|
126
112
|
bag1.__merge!(bag2);
|
127
113
|
|
128
|
-
assert_equal({
|
114
|
+
assert_equal({"first" => "string"}, bag1.__to_hash())
|
129
115
|
end
|
130
116
|
end
|
131
117
|
end
|
@@ -1,128 +1,120 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
require 'tmpdir'
|
3
|
-
|
4
1
|
require 'nugrant/config'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'tmpdir'
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@default_param_filename = Nugrant::Config::DEFAULT_PARAMS_FILENAME
|
5
|
+
class Nugrant::TestConfig < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@default_param_filename = Nugrant::Config::DEFAULT_PARAMS_FILENAME
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
@old_working_dir = Dir.getwd()
|
10
|
+
@user_dir = Nugrant::Config.default_user_path()
|
11
|
+
@system_dir = Nugrant::Config.default_system_path()
|
14
12
|
|
15
|
-
|
13
|
+
Dir.chdir(Dir.tmpdir())
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def teardown
|
21
|
-
Dir.chdir(@old_working_dir)
|
15
|
+
@current_dir = Dir.getwd()
|
16
|
+
end
|
22
17
|
|
23
|
-
|
24
|
-
|
25
|
-
@user_dir = nil
|
26
|
-
@system_dir = nil
|
27
|
-
end
|
18
|
+
def teardown
|
19
|
+
Dir.chdir(@old_working_dir)
|
28
20
|
|
29
|
-
|
30
|
-
|
21
|
+
@old_working_dir = nil
|
22
|
+
@current_dir = nil
|
23
|
+
@user_dir = nil
|
24
|
+
@system_dir = nil
|
25
|
+
end
|
31
26
|
|
32
|
-
|
33
|
-
|
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
|
27
|
+
def test_default_values
|
28
|
+
config = Nugrant::Config.new()
|
37
29
|
|
38
|
-
|
39
|
-
|
30
|
+
assert_equal(@default_param_filename, config.params_filename())
|
31
|
+
assert_equal("#{@current_dir}/#{@default_param_filename}", config.current_path())
|
32
|
+
assert_equal("#{@user_dir}/#{@default_param_filename}", config.user_path())
|
33
|
+
assert_equal("#{@system_dir}/#{@default_param_filename}", config.system_path())
|
34
|
+
end
|
40
35
|
|
41
|
-
|
42
|
-
|
43
|
-
assert_equal("#{@user_dir}/.customparams", config.user_params_path())
|
44
|
-
assert_equal("#{@system_dir}/.customparams", config.system_params_path())
|
45
|
-
end
|
36
|
+
def test_custom_params_filename
|
37
|
+
config = Nugrant::Config.new({:params_filename => ".customparams"})
|
46
38
|
|
47
|
-
|
48
|
-
|
39
|
+
assert_equal(".customparams", config.params_filename())
|
40
|
+
assert_equal("#{@current_dir}/.customparams", config.current_path())
|
41
|
+
assert_equal("#{@user_dir}/.customparams", config.user_path())
|
42
|
+
assert_equal("#{@system_dir}/.customparams", config.system_path())
|
43
|
+
end
|
49
44
|
|
50
|
-
|
45
|
+
def test_custom_current_path
|
46
|
+
config = Nugrant::Config.new({
|
47
|
+
:params_filename => ".customparams",
|
48
|
+
:current_path => "#{@user_dir}/.currentcustomparams"
|
49
|
+
})
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
})
|
51
|
+
assert_equal(".customparams", config.params_filename())
|
52
|
+
assert_equal("#{@user_dir}/.currentcustomparams", config.current_path())
|
53
|
+
end
|
63
54
|
|
64
|
-
|
65
|
-
|
66
|
-
|
55
|
+
def test_custom_user_path
|
56
|
+
config = Nugrant::Config.new({
|
57
|
+
:params_filename => ".customparams",
|
58
|
+
:user_path => "#{@system_dir}/.usercustomparams"
|
59
|
+
})
|
67
60
|
|
68
|
-
|
69
|
-
|
70
|
-
:params_filename => ".customparams",
|
71
|
-
:user_params_path => "#{@system_dir}/.usercustomparams"
|
72
|
-
})
|
61
|
+
assert_equal(".customparams", config.params_filename())
|
62
|
+
assert_equal("#{@system_dir}/.usercustomparams", config.user_path()) end
|
73
63
|
|
74
|
-
|
75
|
-
|
64
|
+
def test_custom_system_path
|
65
|
+
config = Nugrant::Config.new({
|
66
|
+
:params_filename => ".customparams",
|
67
|
+
:system_path => "#{@current_dir}/.systemcustomparams"
|
68
|
+
})
|
76
69
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
:system_params_path => "#{@project_dir}/.systemcustomparams"
|
81
|
-
})
|
70
|
+
assert_equal(".customparams", config.params_filename())
|
71
|
+
assert_equal("#{@current_dir}/.systemcustomparams", config.system_path())
|
72
|
+
end
|
82
73
|
|
83
|
-
|
84
|
-
|
85
|
-
|
74
|
+
def test_custom_all
|
75
|
+
config = Nugrant::Config.new({
|
76
|
+
:params_filename => ".customparams",
|
77
|
+
:current_path => "#{@user_dir}/.currentcustomparams",
|
78
|
+
:user_path => "#{@system_dir}/.usercustomparams",
|
79
|
+
:system_path => "#{@current_dir}/.systemcustomparams"
|
80
|
+
})
|
81
|
+
|
82
|
+
assert_equal(".customparams", config.params_filename())
|
83
|
+
assert_equal("#{@user_dir}/.currentcustomparams", config.current_path())
|
84
|
+
assert_equal("#{@system_dir}/.usercustomparams", config.user_path())
|
85
|
+
assert_equal("#{@current_dir}/.systemcustomparams", config.system_path())
|
86
|
+
end
|
86
87
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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
|
88
|
+
def test_nil_current
|
89
|
+
config = Nugrant::Config.new({
|
90
|
+
:params_filename => ".customparams",
|
91
|
+
:current_path => nil,
|
92
|
+
})
|
100
93
|
|
101
|
-
|
102
|
-
|
103
|
-
:params_filename => ".customparams",
|
104
|
-
:project_params_path => nil,
|
105
|
-
})
|
94
|
+
assert_not_nil("#{@current_dir}/.customparams", config.current_path())
|
95
|
+
end
|
106
96
|
|
107
|
-
|
108
|
-
|
97
|
+
def test_nil_user
|
98
|
+
config = Nugrant::Config.new({
|
99
|
+
:params_filename => ".customparams",
|
100
|
+
:user_path => nil,
|
101
|
+
})
|
109
102
|
|
110
|
-
|
111
|
-
|
112
|
-
:params_filename => ".customparams",
|
113
|
-
:user_params_path => nil,
|
114
|
-
})
|
103
|
+
assert_equal("#{@user_dir}/.customparams", config.user_path())
|
104
|
+
end
|
115
105
|
|
116
|
-
|
117
|
-
|
106
|
+
def test_nil_system
|
107
|
+
config = Nugrant::Config.new({
|
108
|
+
:params_filename => ".customparams",
|
109
|
+
:system_path => nil,
|
110
|
+
})
|
118
111
|
|
119
|
-
|
120
|
-
|
121
|
-
:params_filename => ".customparams",
|
122
|
-
:system_params_path => nil,
|
123
|
-
})
|
112
|
+
assert_equal("#{@system_dir}/.customparams", config.system_path())
|
113
|
+
end
|
124
114
|
|
125
|
-
|
115
|
+
def test_invalid_format
|
116
|
+
assert_raise(ArgumentError) do
|
117
|
+
Nugrant::Config.new({:params_format => :invalid})
|
126
118
|
end
|
127
119
|
end
|
128
120
|
end
|
@@ -1,257 +1,240 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
|
3
1
|
require 'nugrant'
|
4
2
|
require 'nugrant/parameters'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class Nugrant::TestParameters < Test::Unit::TestCase
|
6
|
+
@@FORMATS = [:json, :yaml]
|
7
|
+
@@INVALID_PATH = "impossible_file_path.yamljson.impossible"
|
8
|
+
|
9
|
+
def create_parameters(format, current_filename, user_filename, system_filename)
|
10
|
+
extension = case
|
11
|
+
when format = :json
|
12
|
+
"json"
|
13
|
+
when format = :yaml
|
14
|
+
"yml"
|
15
|
+
else
|
16
|
+
raise ArgumentError, "Format [#{format}] is currently not supported"
|
17
|
+
end
|
18
|
+
|
19
|
+
resource_path = File.expand_path("#{File.dirname(__FILE__)}/../../resources/#{format}")
|
20
|
+
|
21
|
+
current_path = "#{resource_path}/#{current_filename}.#{extension}" if current_filename
|
22
|
+
user_path = "#{resource_path}/#{user_filename}.#{extension}" if user_filename
|
23
|
+
system_path = "#{resource_path}/#{system_filename}.#{extension}" if system_filename
|
24
|
+
|
25
|
+
return Nugrant::Parameters.new({
|
26
|
+
:config => {
|
27
|
+
:format => format,
|
28
|
+
:current_path => current_path,
|
29
|
+
:user_path => user_path,
|
30
|
+
:system_path => system_path,
|
31
|
+
},
|
32
|
+
})
|
33
|
+
end
|
5
34
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
35
|
+
def assert_level(parameters, results)
|
36
|
+
results.each do |key, value|
|
37
|
+
assert_equal(value, parameters.send(key), "array[#{key}]")
|
38
|
+
assert_equal(value, parameters[key], "array[#{key}]")
|
39
|
+
end
|
11
40
|
|
12
|
-
|
13
|
-
|
41
|
+
assert_key_error(parameters, "0.0.0")
|
42
|
+
end
|
14
43
|
|
15
|
-
|
16
|
-
|
17
|
-
|
44
|
+
def assert_key_error(parameters, key)
|
45
|
+
assert_raise(KeyError) do
|
46
|
+
parameters[key]
|
47
|
+
end
|
48
|
+
end
|
18
49
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
50
|
+
def test_params_level_1()
|
51
|
+
formats.each do |format|
|
52
|
+
parameters = create_parameters(format, "params_current_1", "params_user_1", "params_system_1")
|
53
|
+
|
54
|
+
assert_level(parameters, {
|
55
|
+
"1.1.1" => "current",
|
56
|
+
"1.1.0" => "current",
|
57
|
+
"1.0.1" => "current",
|
58
|
+
"0.1.1" => "user",
|
59
|
+
"1.0.0" => "current",
|
60
|
+
"0.1.0" => "user",
|
61
|
+
"0.0.1" => "system",
|
24
62
|
})
|
25
63
|
end
|
64
|
+
end
|
26
65
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
66
|
+
def test_params_level_2()
|
67
|
+
formats.each do |format|
|
68
|
+
parameters = create_parameters(format, "params_current_2", "params_user_2", "params_system_2")
|
69
|
+
|
70
|
+
run_second_level(parameters, "1.1.1", {
|
71
|
+
"1.1.1" => "current",
|
72
|
+
"1.1.0" => "current",
|
73
|
+
"1.0.1" => "current",
|
74
|
+
"0.1.1" => "user",
|
75
|
+
"1.0.0" => "current",
|
76
|
+
"0.1.0" => "user",
|
77
|
+
"0.0.1" => "system",
|
78
|
+
})
|
32
79
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
80
|
+
run_second_level(parameters, "1.1.0", {
|
81
|
+
"1.1.1" => "current",
|
82
|
+
"1.1.0" => "current",
|
83
|
+
"1.0.1" => "current",
|
84
|
+
"0.1.1" => "user",
|
85
|
+
"1.0.0" => "current",
|
86
|
+
"0.1.0" => "user",
|
87
|
+
})
|
37
88
|
|
38
|
-
|
39
|
-
|
89
|
+
run_second_level(parameters, "1.0.1", {
|
90
|
+
"1.1.1" => "current",
|
91
|
+
"1.1.0" => "current",
|
92
|
+
"1.0.1" => "current",
|
93
|
+
"0.1.1" => "system",
|
94
|
+
"1.0.0" => "current",
|
95
|
+
"0.0.1" => "system",
|
96
|
+
})
|
40
97
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
98
|
+
run_second_level(parameters, "0.1.1", {
|
99
|
+
"1.1.1" => "user",
|
100
|
+
"1.1.0" => "user",
|
101
|
+
"1.0.1" => "system",
|
102
|
+
"0.1.1" => "user",
|
103
|
+
"0.1.0" => "user",
|
104
|
+
"0.0.1" => "system",
|
105
|
+
})
|
46
106
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
107
|
+
run_second_level(parameters, "1.0.0", {
|
108
|
+
"1.1.1" => "current",
|
109
|
+
"1.1.0" => "current",
|
110
|
+
"1.0.1" => "current",
|
111
|
+
"1.0.0" => "current",
|
112
|
+
})
|
62
113
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
114
|
+
run_second_level(parameters, "0.1.0", {
|
115
|
+
"1.1.1" => "user",
|
116
|
+
"1.1.0" => "user",
|
117
|
+
"0.1.1" => "user",
|
118
|
+
"0.1.0" => "user",
|
119
|
+
})
|
128
120
|
|
129
|
-
|
130
|
-
|
131
|
-
|
121
|
+
run_second_level(parameters, "0.0.1", {
|
122
|
+
"1.1.1" => "system",
|
123
|
+
"1.0.1" => "system",
|
124
|
+
"0.1.1" => "system",
|
125
|
+
"0.0.1" => "system",
|
126
|
+
})
|
132
127
|
|
133
128
|
assert_key_error(parameters, "0.0.0")
|
134
129
|
end
|
130
|
+
end
|
135
131
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
parameters = create_parameters(params_filetype, file_path, invalid_path, invalid_path)
|
132
|
+
def run_second_level(parameters, key, results)
|
133
|
+
assert_level(parameters.send(key), results)
|
134
|
+
assert_level(parameters[key], results)
|
140
135
|
|
141
|
-
|
142
|
-
|
143
|
-
end
|
136
|
+
assert_key_error(parameters, "0.0.0")
|
137
|
+
end
|
144
138
|
|
145
|
-
|
146
|
-
|
147
|
-
|
139
|
+
def test_params_array()
|
140
|
+
file_path = "params_array"
|
141
|
+
formats.each do |format|
|
142
|
+
parameters = create_parameters(format, file_path, invalid_path, invalid_path)
|
148
143
|
|
149
|
-
|
150
|
-
run_test_file_invalid("impossible_file_path.yml.impossible")
|
144
|
+
assert_equal(["1", "2", "3"], parameters['level1']['level2'])
|
151
145
|
end
|
146
|
+
end
|
152
147
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
assert_all_access_equal("value", parameters, "test")
|
148
|
+
def test_file_nil()
|
149
|
+
run_test_file_invalid(nil)
|
150
|
+
end
|
157
151
|
|
158
|
-
|
159
|
-
|
152
|
+
def test_file_does_not_exist()
|
153
|
+
run_test_file_invalid("impossible_file_path.yml.impossible")
|
154
|
+
end
|
160
155
|
|
161
|
-
|
162
|
-
|
156
|
+
def run_test_file_invalid(invalid_value)
|
157
|
+
formats.each do |format|
|
158
|
+
parameters = create_parameters(format, "params_simple", invalid_path, invalid_path)
|
159
|
+
assert_equal("value", parameters["test"])
|
163
160
|
|
164
|
-
|
165
|
-
|
166
|
-
end
|
167
|
-
end
|
161
|
+
parameters = create_parameters(format, invalid_path, "params_simple", invalid_path)
|
162
|
+
assert_equal("value", parameters["test"])
|
168
163
|
|
169
|
-
|
170
|
-
|
171
|
-
end
|
164
|
+
parameters = create_parameters(format, invalid_path, invalid_path, "params_simple")
|
165
|
+
assert_equal("value", parameters["test"])
|
172
166
|
|
173
|
-
|
174
|
-
|
175
|
-
end
|
176
|
-
|
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)
|
180
|
-
|
181
|
-
assert_all_access_equal("value1", parameters, 'level1')
|
182
|
-
assert_all_access_equal("value2", parameters['level2'], 'first')
|
183
|
-
end
|
167
|
+
parameters = create_parameters(format, invalid_path, invalid_path, invalid_path)
|
168
|
+
assert_not_nil(parameters)
|
184
169
|
end
|
170
|
+
end
|
185
171
|
|
186
|
-
|
187
|
-
|
188
|
-
|
172
|
+
def test_params_windows_eol()
|
173
|
+
run_test_params_eol("params_windows_eol")
|
174
|
+
end
|
189
175
|
|
190
|
-
|
191
|
-
|
176
|
+
def test_params_unix_eol()
|
177
|
+
run_test_params_eol("params_unix_eol")
|
178
|
+
end
|
192
179
|
|
193
|
-
|
194
|
-
|
180
|
+
def run_test_params_eol(file_path)
|
181
|
+
formats.each do |format|
|
182
|
+
parameters = create_parameters(format, file_path, invalid_path, invalid_path)
|
195
183
|
|
196
|
-
|
197
|
-
|
184
|
+
assert_equal("value1", parameters['level1'])
|
185
|
+
assert_equal("value2", parameters['level2']['first'])
|
198
186
|
end
|
187
|
+
end
|
199
188
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
parameters.defaults = {"test" => "override1", "level" => "new1"}
|
189
|
+
def test_restricted_defaults_usage()
|
190
|
+
formats.each do |format|
|
191
|
+
parameters = create_parameters(format, "params_defaults_at_root", invalid_path, invalid_path)
|
204
192
|
|
205
|
-
|
206
|
-
assert_all_access_equal("new1", parameters, 'level')
|
207
|
-
end
|
193
|
+
assert_equal("value", parameters.defaults)
|
208
194
|
end
|
209
195
|
|
210
|
-
|
211
|
-
|
212
|
-
parameters = create_parameters(params_filetype, "params_empty", invalid_path, invalid_path)
|
213
|
-
parameters.defaults = {"test" => "value"}
|
196
|
+
formats.each do |format|
|
197
|
+
parameters = create_parameters(format, "params_defaults_not_at_root", invalid_path, invalid_path)
|
214
198
|
|
215
|
-
|
216
|
-
end
|
199
|
+
assert_equal("value", parameters.level.defaults)
|
217
200
|
end
|
201
|
+
end
|
218
202
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
parameters.defaults = {"test" => "value"}
|
203
|
+
def test_defaults()
|
204
|
+
formats.each do |format|
|
205
|
+
parameters = create_parameters(format, "params_simple", invalid_path, invalid_path)
|
206
|
+
parameters.defaults = {"test" => "override1", "level" => "new1"}
|
224
207
|
|
225
|
-
|
226
|
-
|
227
|
-
end
|
208
|
+
assert_equal("value", parameters['test'])
|
209
|
+
assert_equal("new1", parameters['level'])
|
228
210
|
end
|
211
|
+
end
|
229
212
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
213
|
+
def test_empty_file()
|
214
|
+
formats.each do |format|
|
215
|
+
parameters = create_parameters(format, "params_empty", invalid_path, invalid_path)
|
216
|
+
parameters.defaults = {"test" => "value"}
|
234
217
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
end
|
218
|
+
assert_equal("value", parameters['test'])
|
219
|
+
end
|
220
|
+
end
|
239
221
|
|
240
|
-
|
241
|
-
|
222
|
+
def test_file_not_hash()
|
223
|
+
["boolean", "list"].each do |wrong_type|
|
224
|
+
formats.each do |format|
|
225
|
+
parameters = create_parameters(format, "params_#{wrong_type}", invalid_path, invalid_path)
|
226
|
+
parameters.defaults = {"test" => "value"}
|
242
227
|
|
243
|
-
|
244
|
-
assert_all_access_equal(nil, parameters[:deep], :nil)
|
245
|
-
assert_all_access_equal(nil, parameters, :nil)
|
228
|
+
assert_equal("value", parameters['test'])
|
246
229
|
end
|
247
230
|
end
|
231
|
+
end
|
248
232
|
|
249
|
-
|
250
|
-
|
251
|
-
|
233
|
+
def formats()
|
234
|
+
@@FORMATS
|
235
|
+
end
|
252
236
|
|
253
|
-
|
254
|
-
|
255
|
-
end
|
237
|
+
def invalid_path()
|
238
|
+
@@INVALID_PATH
|
256
239
|
end
|
257
240
|
end
|