test-kitchen 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cane +1 -1
- data/.rubocop.yml +3 -0
- data/.travis.yml +20 -9
- data/CHANGELOG.md +219 -108
- data/Gemfile +10 -6
- data/Guardfile +38 -9
- data/README.md +11 -1
- data/Rakefile +21 -37
- data/bin/kitchen +4 -4
- data/features/kitchen_action_commands.feature +161 -0
- data/features/kitchen_console_command.feature +34 -0
- data/features/kitchen_diagnose_command.feature +64 -0
- data/features/kitchen_init_command.feature +29 -17
- data/features/kitchen_list_command.feature +2 -2
- data/features/kitchen_login_command.feature +56 -0
- data/features/{sink_command.feature → kitchen_sink_command.feature} +0 -0
- data/features/kitchen_test_command.feature +88 -0
- data/features/step_definitions/gem_steps.rb +8 -6
- data/features/step_definitions/git_steps.rb +4 -2
- data/features/step_definitions/output_steps.rb +5 -0
- data/features/support/env.rb +12 -9
- data/lib/kitchen.rb +60 -38
- data/lib/kitchen/base64_stream.rb +55 -0
- data/lib/kitchen/busser.rb +124 -58
- data/lib/kitchen/cli.rb +121 -38
- data/lib/kitchen/collection.rb +3 -3
- data/lib/kitchen/color.rb +4 -4
- data/lib/kitchen/command.rb +78 -11
- data/lib/kitchen/command/action.rb +3 -2
- data/lib/kitchen/command/console.rb +12 -5
- data/lib/kitchen/command/diagnose.rb +17 -3
- data/lib/kitchen/command/driver_discover.rb +26 -7
- data/lib/kitchen/command/exec.rb +41 -0
- data/lib/kitchen/command/list.rb +44 -14
- data/lib/kitchen/command/login.rb +2 -1
- data/lib/kitchen/command/sink.rb +2 -1
- data/lib/kitchen/command/test.rb +5 -4
- data/lib/kitchen/config.rb +146 -14
- data/lib/kitchen/configurable.rb +314 -0
- data/lib/kitchen/data_munger.rb +522 -18
- data/lib/kitchen/diagnostic.rb +43 -4
- data/lib/kitchen/driver.rb +4 -4
- data/lib/kitchen/driver/base.rb +80 -115
- data/lib/kitchen/driver/dummy.rb +34 -6
- data/lib/kitchen/driver/proxy.rb +14 -3
- data/lib/kitchen/driver/ssh_base.rb +61 -7
- data/lib/kitchen/errors.rb +109 -9
- data/lib/kitchen/generator/driver_create.rb +39 -5
- data/lib/kitchen/generator/init.rb +130 -45
- data/lib/kitchen/instance.rb +162 -28
- data/lib/kitchen/lazy_hash.rb +79 -7
- data/lib/kitchen/loader/yaml.rb +159 -27
- data/lib/kitchen/logger.rb +267 -21
- data/lib/kitchen/logging.rb +30 -3
- data/lib/kitchen/login_command.rb +11 -2
- data/lib/kitchen/metadata_chopper.rb +2 -2
- data/lib/kitchen/provisioner.rb +4 -4
- data/lib/kitchen/provisioner/base.rb +107 -103
- data/lib/kitchen/provisioner/chef/berkshelf.rb +36 -8
- data/lib/kitchen/provisioner/chef/librarian.rb +40 -11
- data/lib/kitchen/provisioner/chef_base.rb +206 -167
- data/lib/kitchen/provisioner/chef_solo.rb +25 -7
- data/lib/kitchen/provisioner/chef_zero.rb +105 -29
- data/lib/kitchen/provisioner/dummy.rb +1 -1
- data/lib/kitchen/provisioner/shell.rb +21 -6
- data/lib/kitchen/rake_tasks.rb +8 -3
- data/lib/kitchen/shell_out.rb +15 -18
- data/lib/kitchen/ssh.rb +122 -27
- data/lib/kitchen/state_file.rb +24 -7
- data/lib/kitchen/thor_tasks.rb +9 -4
- data/lib/kitchen/util.rb +43 -118
- data/lib/kitchen/version.rb +1 -1
- data/lib/vendor/hash_recursive_merge.rb +10 -2
- data/spec/kitchen/base64_stream_spec.rb +77 -0
- data/spec/kitchen/busser_spec.rb +490 -0
- data/spec/kitchen/collection_spec.rb +10 -10
- data/spec/kitchen/color_spec.rb +2 -2
- data/spec/kitchen/config_spec.rb +234 -62
- data/spec/kitchen/configurable_spec.rb +490 -0
- data/spec/kitchen/data_munger_spec.rb +1070 -862
- data/spec/kitchen/diagnostic_spec.rb +79 -0
- data/spec/kitchen/driver/base_spec.rb +80 -85
- data/spec/kitchen/driver/dummy_spec.rb +43 -14
- data/spec/kitchen/driver/proxy_spec.rb +134 -0
- data/spec/kitchen/driver/ssh_base_spec.rb +644 -0
- data/spec/kitchen/driver_spec.rb +15 -15
- data/spec/kitchen/errors_spec.rb +309 -0
- data/spec/kitchen/instance_spec.rb +143 -46
- data/spec/kitchen/lazy_hash_spec.rb +36 -9
- data/spec/kitchen/loader/yaml_spec.rb +237 -226
- data/spec/kitchen/logger_spec.rb +419 -0
- data/spec/kitchen/logging_spec.rb +59 -0
- data/spec/kitchen/login_command_spec.rb +49 -0
- data/spec/kitchen/metadata_chopper_spec.rb +82 -0
- data/spec/kitchen/platform_spec.rb +4 -4
- data/spec/kitchen/provisioner/base_spec.rb +65 -125
- data/spec/kitchen/provisioner/chef_base_spec.rb +798 -0
- data/spec/kitchen/provisioner/chef_solo_spec.rb +316 -0
- data/spec/kitchen/provisioner/chef_zero_spec.rb +624 -0
- data/spec/kitchen/provisioner/shell_spec.rb +269 -0
- data/spec/kitchen/provisioner_spec.rb +6 -6
- data/spec/kitchen/shell_out_spec.rb +143 -0
- data/spec/kitchen/ssh_spec.rb +683 -0
- data/spec/kitchen/state_file_spec.rb +28 -21
- data/spec/kitchen/suite_spec.rb +7 -7
- data/spec/kitchen/util_spec.rb +68 -10
- data/spec/kitchen_spec.rb +107 -0
- data/spec/spec_helper.rb +18 -13
- data/support/chef-client-zero.rb +10 -9
- data/support/chef_helpers.sh +16 -0
- data/support/download_helpers.sh +109 -0
- data/test-kitchen.gemspec +42 -33
- metadata +107 -33
@@ -16,9 +16,9 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
-
require_relative
|
19
|
+
require_relative "../spec_helper"
|
20
20
|
|
21
|
-
require
|
21
|
+
require "kitchen/lazy_hash"
|
22
22
|
|
23
23
|
describe Kitchen::LazyHash do
|
24
24
|
|
@@ -26,33 +26,60 @@ describe Kitchen::LazyHash do
|
|
26
26
|
stub(:color => "blue", :metal => "heavy")
|
27
27
|
end
|
28
28
|
|
29
|
-
let(:
|
29
|
+
let(:hash_obj) do
|
30
30
|
{
|
31
|
-
:shed_color =>
|
31
|
+
:shed_color => ->(c) { c.color },
|
32
32
|
:barn => "locked",
|
33
|
-
:genre =>
|
33
|
+
:genre => proc { |c| "#{c.metal} metal" }
|
34
34
|
}
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "#[]" do
|
38
38
|
|
39
39
|
it "returns regular values for keys" do
|
40
|
-
Kitchen::LazyHash.new(
|
40
|
+
Kitchen::LazyHash.new(hash_obj, context)[:barn].must_equal "locked"
|
41
41
|
end
|
42
42
|
|
43
43
|
it "invokes call on values that are lambdas" do
|
44
|
-
Kitchen::LazyHash.new(
|
44
|
+
Kitchen::LazyHash.new(hash_obj, context)[:shed_color].must_equal "blue"
|
45
45
|
end
|
46
46
|
|
47
47
|
it "invokes call on values that are Procs" do
|
48
|
-
Kitchen::LazyHash.new(
|
48
|
+
Kitchen::LazyHash.new(hash_obj, context)[:genre].must_equal "heavy metal"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#fetch" do
|
53
|
+
|
54
|
+
it "returns regular hash values for keys" do
|
55
|
+
Kitchen::LazyHash.new(hash_obj, context).fetch(:barn).must_equal "locked"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "invokes call on values that are lambdas" do
|
59
|
+
Kitchen::LazyHash.new(hash_obj, context).
|
60
|
+
fetch(:shed_color).must_equal "blue"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "invokes call on values that are Procs" do
|
64
|
+
Kitchen::LazyHash.new(hash_obj, context).
|
65
|
+
fetch(:genre).must_equal "heavy metal"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "uses a default value for unset values" do
|
69
|
+
Kitchen::LazyHash.new(hash_obj, context).
|
70
|
+
fetch(:nope, "candy").must_equal "candy"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "uses a block for unset values" do
|
74
|
+
Kitchen::LazyHash.new(hash_obj, context).
|
75
|
+
fetch(:nope) { |key| "#{key} is costly" }.must_equal "nope is costly"
|
49
76
|
end
|
50
77
|
end
|
51
78
|
|
52
79
|
describe "#to_hash" do
|
53
80
|
|
54
81
|
it "invokes any callable values and returns a Hash object" do
|
55
|
-
converted = Kitchen::LazyHash.new(
|
82
|
+
converted = Kitchen::LazyHash.new(hash_obj, context).to_hash
|
56
83
|
|
57
84
|
converted.must_be_instance_of Hash
|
58
85
|
converted.fetch(:shed_color).must_equal "blue"
|
@@ -16,11 +16,11 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
-
require_relative
|
19
|
+
require_relative "../../spec_helper"
|
20
20
|
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
21
|
+
require "kitchen/errors"
|
22
|
+
require "kitchen/util"
|
23
|
+
require "kitchen/loader/yaml"
|
24
24
|
|
25
25
|
class Yamled
|
26
26
|
attr_accessor :foo
|
@@ -45,60 +45,60 @@ describe Kitchen::Loader::YAML do
|
|
45
45
|
describe ".initialize" do
|
46
46
|
|
47
47
|
it "sets project_config based on Dir.pwd by default" do
|
48
|
-
stub_file(File.join(Dir.pwd,
|
48
|
+
stub_file(File.join(Dir.pwd, ".kitchen.yml"), Hash.new)
|
49
49
|
loader = Kitchen::Loader::YAML.new
|
50
50
|
|
51
51
|
loader.diagnose[:project_config][:filename].
|
52
|
-
must_equal File.expand_path(File.join(Dir.pwd,
|
52
|
+
must_equal File.expand_path(File.join(Dir.pwd, ".kitchen.yml"))
|
53
53
|
end
|
54
54
|
|
55
55
|
it "sets project_config from parameter, if given" do
|
56
|
-
stub_file(
|
56
|
+
stub_file("/tmp/crazyfunkytown.file", Hash.new)
|
57
57
|
loader = Kitchen::Loader::YAML.new(
|
58
|
-
:project_config =>
|
58
|
+
:project_config => "/tmp/crazyfunkytown.file")
|
59
59
|
|
60
60
|
loader.diagnose[:project_config][:filename].
|
61
61
|
must_match %r{/tmp/crazyfunkytown.file$}
|
62
62
|
end
|
63
63
|
|
64
64
|
it "sets local_config based on Dir.pwd by default" do
|
65
|
-
stub_file(File.join(Dir.pwd,
|
65
|
+
stub_file(File.join(Dir.pwd, ".kitchen.local.yml"), Hash.new)
|
66
66
|
loader = Kitchen::Loader::YAML.new
|
67
67
|
|
68
68
|
loader.diagnose[:local_config][:filename].
|
69
|
-
must_equal File.expand_path(File.join(Dir.pwd,
|
69
|
+
must_equal File.expand_path(File.join(Dir.pwd, ".kitchen.local.yml"))
|
70
70
|
end
|
71
71
|
|
72
72
|
it "sets local_config based on location of project_config by default" do
|
73
|
-
stub_file(
|
73
|
+
stub_file("/tmp/.kitchen.local.yml", Hash.new)
|
74
74
|
loader = Kitchen::Loader::YAML.new(
|
75
|
-
:project_config =>
|
75
|
+
:project_config => "/tmp/.kitchen.yml")
|
76
76
|
|
77
77
|
loader.diagnose[:local_config][:filename].
|
78
78
|
must_match %r{/tmp/.kitchen.local.yml$}
|
79
79
|
end
|
80
80
|
|
81
81
|
it "sets local_config from parameter, if given" do
|
82
|
-
stub_file(
|
82
|
+
stub_file("/tmp/crazyfunkytown.file", Hash.new)
|
83
83
|
loader = Kitchen::Loader::YAML.new(
|
84
|
-
:local_config =>
|
84
|
+
:local_config => "/tmp/crazyfunkytown.file")
|
85
85
|
|
86
86
|
loader.diagnose[:local_config][:filename].
|
87
87
|
must_match %r{/tmp/crazyfunkytown.file$}
|
88
88
|
end
|
89
89
|
|
90
90
|
it "sets global_config based on ENV['HOME'] by default" do
|
91
|
-
stub_file(File.join(ENV[
|
91
|
+
stub_file(File.join(ENV["HOME"], ".kitchen/config.yml"), Hash.new)
|
92
92
|
loader = Kitchen::Loader::YAML.new
|
93
93
|
|
94
94
|
loader.diagnose[:global_config][:filename].must_equal File.expand_path(
|
95
|
-
File.join(ENV[
|
95
|
+
File.join(ENV["HOME"], ".kitchen/config.yml"))
|
96
96
|
end
|
97
97
|
|
98
98
|
it "sets global_config from parameter, if given" do
|
99
|
-
stub_file(
|
99
|
+
stub_file("/tmp/crazyfunkytown.file", Hash.new)
|
100
100
|
loader = Kitchen::Loader::YAML.new(
|
101
|
-
:global_config =>
|
101
|
+
:global_config => "/tmp/crazyfunkytown.file")
|
102
102
|
|
103
103
|
loader.diagnose[:global_config][:filename].
|
104
104
|
must_match %r{/tmp/crazyfunkytown.file$}
|
@@ -108,75 +108,86 @@ describe Kitchen::Loader::YAML do
|
|
108
108
|
describe "#read" do
|
109
109
|
|
110
110
|
it "returns a hash of kitchen.yml with symbolized keys" do
|
111
|
-
stub_yaml!(
|
112
|
-
|
113
|
-
|
111
|
+
stub_yaml!(
|
112
|
+
"foo" => "bar"
|
113
|
+
)
|
114
114
|
|
115
|
-
loader.read.must_equal(
|
115
|
+
loader.read.must_equal(:foo => "bar")
|
116
116
|
end
|
117
117
|
|
118
118
|
it "deep merges in kitchen.local.yml configuration with kitchen.yml" do
|
119
|
-
stub_yaml!(".kitchen.yml",
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
stub_yaml!(".kitchen.local.yml",
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
loader.read.must_equal(
|
129
|
-
:a =>
|
130
|
-
:c =>
|
119
|
+
stub_yaml!(".kitchen.yml",
|
120
|
+
"common" => { "xx" => 1 },
|
121
|
+
"a" => "b"
|
122
|
+
)
|
123
|
+
stub_yaml!(".kitchen.local.yml",
|
124
|
+
"common" => { "yy" => 2 },
|
125
|
+
"c" => "d"
|
126
|
+
)
|
127
|
+
|
128
|
+
loader.read.must_equal(
|
129
|
+
:a => "b",
|
130
|
+
:c => "d",
|
131
131
|
:common => { :xx => 1, :yy => 2 }
|
132
|
-
|
132
|
+
)
|
133
133
|
end
|
134
134
|
|
135
135
|
it "deep merges in a global config file with all other configs" do
|
136
|
-
stub_yaml!(".kitchen.yml",
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
stub_yaml!(".kitchen.local.yml",
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
stub_global!(
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
loader.read.must_equal(
|
150
|
-
:a =>
|
151
|
-
:c =>
|
152
|
-
:e =>
|
136
|
+
stub_yaml!(".kitchen.yml",
|
137
|
+
"common" => { "xx" => 1 },
|
138
|
+
"a" => "b"
|
139
|
+
)
|
140
|
+
stub_yaml!(".kitchen.local.yml",
|
141
|
+
"common" => { "yy" => 2 },
|
142
|
+
"c" => "d"
|
143
|
+
)
|
144
|
+
stub_global!(
|
145
|
+
"common" => { "zz" => 3 },
|
146
|
+
"e" => "f"
|
147
|
+
)
|
148
|
+
|
149
|
+
loader.read.must_equal(
|
150
|
+
:a => "b",
|
151
|
+
:c => "d",
|
152
|
+
:e => "f",
|
153
153
|
:common => { :xx => 1, :yy => 2, :zz => 3 }
|
154
|
-
|
154
|
+
)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "merges kitchen.yml over configuration in global config" do
|
158
|
+
stub_global!(
|
159
|
+
"common" => { "thekey" => "nope" }
|
160
|
+
)
|
161
|
+
stub_yaml!(".kitchen.yml",
|
162
|
+
"common" => { "thekey" => "yep" }
|
163
|
+
)
|
164
|
+
|
165
|
+
loader.read.must_equal(:common => { :thekey => "yep" })
|
155
166
|
end
|
156
167
|
|
157
168
|
it "merges kitchen.local.yml over configuration in kitchen.yml" do
|
158
|
-
stub_yaml!(".kitchen.yml",
|
159
|
-
|
160
|
-
|
161
|
-
stub_yaml!(".kitchen.local.yml",
|
162
|
-
|
163
|
-
|
169
|
+
stub_yaml!(".kitchen.yml",
|
170
|
+
"common" => { "thekey" => "nope" }
|
171
|
+
)
|
172
|
+
stub_yaml!(".kitchen.local.yml",
|
173
|
+
"common" => { "thekey" => "yep" }
|
174
|
+
)
|
164
175
|
|
165
|
-
loader.read.must_equal(
|
176
|
+
loader.read.must_equal(:common => { :thekey => "yep" })
|
166
177
|
end
|
167
178
|
|
168
|
-
it "merges
|
169
|
-
stub_yaml!(".kitchen.yml",
|
170
|
-
|
171
|
-
|
172
|
-
stub_yaml!(".kitchen.local.yml",
|
173
|
-
|
174
|
-
|
175
|
-
stub_global!(
|
176
|
-
|
177
|
-
|
179
|
+
it "merges kitchen.local.yml over both kitchen.yml and global config" do
|
180
|
+
stub_yaml!(".kitchen.yml",
|
181
|
+
"common" => { "thekey" => "nope" }
|
182
|
+
)
|
183
|
+
stub_yaml!(".kitchen.local.yml",
|
184
|
+
"common" => { "thekey" => "yep" }
|
185
|
+
)
|
186
|
+
stub_global!(
|
187
|
+
"common" => { "thekey" => "kinda" }
|
188
|
+
)
|
178
189
|
|
179
|
-
loader.read.must_equal(
|
190
|
+
loader.read.must_equal(:common => { :thekey => "yep" })
|
180
191
|
end
|
181
192
|
|
182
193
|
NORMALIZED_KEYS = {
|
@@ -190,152 +201,152 @@ describe Kitchen::Loader::YAML do
|
|
190
201
|
describe "normalizing #{key} config hashes" do
|
191
202
|
|
192
203
|
it "merges local with #{key} string value over yaml with hash value" do
|
193
|
-
stub_yaml!(".kitchen.yml",
|
194
|
-
key => {
|
195
|
-
|
196
|
-
stub_yaml!(".kitchen.local.yml",
|
197
|
-
key =>
|
198
|
-
|
199
|
-
|
200
|
-
loader.read.must_equal(
|
201
|
-
key.to_sym => { default_key.to_sym => "namey", :dakey =>
|
202
|
-
|
204
|
+
stub_yaml!(".kitchen.yml",
|
205
|
+
key => { "dakey" => "ya" }
|
206
|
+
)
|
207
|
+
stub_yaml!(".kitchen.local.yml",
|
208
|
+
key => "namey"
|
209
|
+
)
|
210
|
+
|
211
|
+
loader.read.must_equal(
|
212
|
+
key.to_sym => { default_key.to_sym => "namey", :dakey => "ya" }
|
213
|
+
)
|
203
214
|
end
|
204
215
|
|
205
216
|
it "merges local with #{key} hash value over yaml with string value" do
|
206
|
-
stub_yaml!(".kitchen.yml",
|
207
|
-
key =>
|
208
|
-
|
209
|
-
stub_yaml!(".kitchen.local.yml",
|
210
|
-
key => {
|
211
|
-
|
212
|
-
|
213
|
-
loader.read.must_equal(
|
214
|
-
key.to_sym => { default_key.to_sym => "namey", :dakey =>
|
215
|
-
|
217
|
+
stub_yaml!(".kitchen.yml",
|
218
|
+
key => "namey"
|
219
|
+
)
|
220
|
+
stub_yaml!(".kitchen.local.yml",
|
221
|
+
key => { "dakey" => "ya" }
|
222
|
+
)
|
223
|
+
|
224
|
+
loader.read.must_equal(
|
225
|
+
key.to_sym => { default_key.to_sym => "namey", :dakey => "ya" }
|
226
|
+
)
|
216
227
|
end
|
217
228
|
|
218
229
|
it "merges local with #{key} nil value over yaml with hash value" do
|
219
|
-
stub_yaml!(".kitchen.yml",
|
220
|
-
key => {
|
221
|
-
|
222
|
-
stub_yaml!(".kitchen.local.yml",
|
230
|
+
stub_yaml!(".kitchen.yml",
|
231
|
+
key => { "dakey" => "ya" }
|
232
|
+
)
|
233
|
+
stub_yaml!(".kitchen.local.yml",
|
223
234
|
key => nil
|
224
|
-
|
235
|
+
)
|
225
236
|
|
226
|
-
loader.read.must_equal(
|
227
|
-
key.to_sym => { :dakey =>
|
228
|
-
|
237
|
+
loader.read.must_equal(
|
238
|
+
key.to_sym => { :dakey => "ya" }
|
239
|
+
)
|
229
240
|
end
|
230
241
|
|
231
242
|
it "merges local with #{key} hash value over yaml with nil value" do
|
232
|
-
stub_yaml!(".kitchen.yml",
|
233
|
-
key =>
|
234
|
-
|
235
|
-
stub_yaml!(".kitchen.local.yml",
|
243
|
+
stub_yaml!(".kitchen.yml",
|
244
|
+
key => "namey"
|
245
|
+
)
|
246
|
+
stub_yaml!(".kitchen.local.yml",
|
236
247
|
key => nil
|
237
|
-
|
248
|
+
)
|
238
249
|
|
239
|
-
loader.read.must_equal(
|
250
|
+
loader.read.must_equal(
|
240
251
|
key.to_sym => { default_key.to_sym => "namey" }
|
241
|
-
|
252
|
+
)
|
242
253
|
end
|
243
254
|
|
244
255
|
it "merges global with #{key} string value over yaml with hash value" do
|
245
|
-
stub_yaml!(".kitchen.yml",
|
246
|
-
key => {
|
247
|
-
|
248
|
-
stub_global!(
|
249
|
-
key =>
|
250
|
-
|
251
|
-
|
252
|
-
loader.read.must_equal(
|
253
|
-
key.to_sym => { default_key.to_sym => "namey", :dakey =>
|
254
|
-
|
256
|
+
stub_yaml!(".kitchen.yml",
|
257
|
+
key => { "dakey" => "ya" }
|
258
|
+
)
|
259
|
+
stub_global!(
|
260
|
+
key => "namey"
|
261
|
+
)
|
262
|
+
|
263
|
+
loader.read.must_equal(
|
264
|
+
key.to_sym => { default_key.to_sym => "namey", :dakey => "ya" }
|
265
|
+
)
|
255
266
|
end
|
256
267
|
|
257
268
|
it "merges global with #{key} hash value over yaml with string value" do
|
258
|
-
stub_yaml!(".kitchen.yml",
|
259
|
-
key =>
|
260
|
-
|
261
|
-
stub_global!(
|
262
|
-
key => {
|
263
|
-
|
264
|
-
|
265
|
-
loader.read.must_equal(
|
266
|
-
key.to_sym => { default_key.to_sym => "namey", :dakey =>
|
267
|
-
|
269
|
+
stub_yaml!(".kitchen.yml",
|
270
|
+
key => "namey"
|
271
|
+
)
|
272
|
+
stub_global!(
|
273
|
+
key => { "dakey" => "ya" }
|
274
|
+
)
|
275
|
+
|
276
|
+
loader.read.must_equal(
|
277
|
+
key.to_sym => { default_key.to_sym => "namey", :dakey => "ya" }
|
278
|
+
)
|
268
279
|
end
|
269
280
|
|
270
281
|
it "merges global with #{key} nil value over yaml with hash value" do
|
271
|
-
stub_yaml!(".kitchen.yml",
|
272
|
-
key => {
|
273
|
-
|
274
|
-
stub_global!(
|
282
|
+
stub_yaml!(".kitchen.yml",
|
283
|
+
key => { "dakey" => "ya" }
|
284
|
+
)
|
285
|
+
stub_global!(
|
275
286
|
key => nil
|
276
|
-
|
287
|
+
)
|
277
288
|
|
278
|
-
loader.read.must_equal(
|
279
|
-
key.to_sym => { :dakey =>
|
280
|
-
|
289
|
+
loader.read.must_equal(
|
290
|
+
key.to_sym => { :dakey => "ya" }
|
291
|
+
)
|
281
292
|
end
|
282
293
|
|
283
294
|
it "merges global with #{key} hash value over yaml with nil value" do
|
284
|
-
stub_yaml!(".kitchen.yml",
|
295
|
+
stub_yaml!(".kitchen.yml",
|
285
296
|
key => nil
|
286
|
-
|
287
|
-
stub_global!(
|
288
|
-
key => {
|
289
|
-
|
290
|
-
|
291
|
-
loader.read.must_equal(
|
292
|
-
key.to_sym => { :dakey =>
|
293
|
-
|
297
|
+
)
|
298
|
+
stub_global!(
|
299
|
+
key => { "dakey" => "ya" }
|
300
|
+
)
|
301
|
+
|
302
|
+
loader.read.must_equal(
|
303
|
+
key.to_sym => { :dakey => "ya" }
|
304
|
+
)
|
294
305
|
end
|
295
306
|
|
296
307
|
it "merges global, local, over yaml with mixed hash, string, nil values" do
|
297
|
-
stub_yaml!(".kitchen.yml",
|
308
|
+
stub_yaml!(".kitchen.yml",
|
298
309
|
key => nil
|
299
|
-
|
300
|
-
stub_yaml!(".kitchen.local.yml",
|
310
|
+
)
|
311
|
+
stub_yaml!(".kitchen.local.yml",
|
301
312
|
key => "namey"
|
302
|
-
|
303
|
-
stub_global!(
|
304
|
-
key => {
|
305
|
-
|
306
|
-
|
307
|
-
loader.read.must_equal(
|
308
|
-
key.to_sym => { default_key.to_sym => "namey", :dakey =>
|
309
|
-
|
313
|
+
)
|
314
|
+
stub_global!(
|
315
|
+
key => { "dakey" => "ya" }
|
316
|
+
)
|
317
|
+
|
318
|
+
loader.read.must_equal(
|
319
|
+
key.to_sym => { default_key.to_sym => "namey", :dakey => "ya" }
|
320
|
+
)
|
310
321
|
end
|
311
322
|
end
|
312
323
|
end
|
313
324
|
|
314
325
|
it "handles a kitchen.local.yml with no yaml elements" do
|
315
|
-
stub_yaml!(".kitchen.yml",
|
316
|
-
|
317
|
-
|
326
|
+
stub_yaml!(".kitchen.yml",
|
327
|
+
"a" => "b"
|
328
|
+
)
|
318
329
|
stub_yaml!(".kitchen.local.yml", Hash.new)
|
319
330
|
|
320
|
-
loader.read.must_equal(
|
331
|
+
loader.read.must_equal(:a => "b")
|
321
332
|
end
|
322
333
|
|
323
334
|
it "handles a kitchen.yml with no yaml elements" do
|
324
335
|
stub_yaml!(".kitchen.yml", Hash.new)
|
325
|
-
stub_yaml!(".kitchen.local.yml",
|
326
|
-
|
327
|
-
|
336
|
+
stub_yaml!(".kitchen.local.yml",
|
337
|
+
"a" => "b"
|
338
|
+
)
|
328
339
|
|
329
|
-
loader.read.must_equal(
|
340
|
+
loader.read.must_equal(:a => "b")
|
330
341
|
end
|
331
342
|
|
332
343
|
it "handles a kitchen.yml with yaml elements that parse as nil" do
|
333
344
|
stub_yaml!(".kitchen.yml", nil)
|
334
|
-
stub_yaml!(".kitchen.local.yml",
|
335
|
-
|
336
|
-
|
345
|
+
stub_yaml!(".kitchen.local.yml",
|
346
|
+
"a" => "b"
|
347
|
+
)
|
337
348
|
|
338
|
-
loader.read.must_equal(
|
349
|
+
loader.read.must_equal(:a => "b")
|
339
350
|
end
|
340
351
|
|
341
352
|
it "raises an UserError if the config_file does not exist" do
|
@@ -345,7 +356,7 @@ describe Kitchen::Loader::YAML do
|
|
345
356
|
it "arbitrary objects aren't deserialized in kitchen.yml" do
|
346
357
|
FileUtils.mkdir_p "/tmp"
|
347
358
|
File.open("/tmp/.kitchen.yml", "wb") do |f|
|
348
|
-
f.write <<-YAML.gsub(/^ {10}/,
|
359
|
+
f.write <<-YAML.gsub(/^ {10}/, "")
|
349
360
|
--- !ruby/object:Yamled
|
350
361
|
foo: bar
|
351
362
|
YAML
|
@@ -353,13 +364,13 @@ describe Kitchen::Loader::YAML do
|
|
353
364
|
|
354
365
|
loader.read.class.wont_equal Yamled
|
355
366
|
loader.read.class.must_equal Hash
|
356
|
-
loader.read.must_equal(
|
367
|
+
loader.read.must_equal(:foo => "bar")
|
357
368
|
end
|
358
369
|
|
359
370
|
it "arbitrary objects aren't deserialized in kitchen.local.yml" do
|
360
371
|
FileUtils.mkdir_p "/tmp"
|
361
372
|
File.open("/tmp/.kitchen.local.yml", "wb") do |f|
|
362
|
-
f.write <<-YAML.gsub(/^ {10}/,
|
373
|
+
f.write <<-YAML.gsub(/^ {10}/, "")
|
363
374
|
--- !ruby/object:Yamled
|
364
375
|
wakka: boop
|
365
376
|
YAML
|
@@ -368,12 +379,12 @@ describe Kitchen::Loader::YAML do
|
|
368
379
|
|
369
380
|
loader.read.class.wont_equal Yamled
|
370
381
|
loader.read.class.must_equal Hash
|
371
|
-
loader.read.must_equal(
|
382
|
+
loader.read.must_equal(:wakka => "boop")
|
372
383
|
end
|
373
384
|
|
374
385
|
it "raises a UserError if kitchen.yml cannot be parsed" do
|
375
386
|
FileUtils.mkdir_p "/tmp"
|
376
|
-
File.open("/tmp/.kitchen.yml", "wb") { |f| f.write
|
387
|
+
File.open("/tmp/.kitchen.yml", "wb") { |f| f.write "&*%^*" }
|
377
388
|
|
378
389
|
err = proc { loader.read }.must_raise Kitchen::UserError
|
379
390
|
err.message.must_match Regexp.new(
|
@@ -382,7 +393,7 @@ describe Kitchen::Loader::YAML do
|
|
382
393
|
|
383
394
|
it "raises a UserError if kitchen.yml cannot be parsed" do
|
384
395
|
FileUtils.mkdir_p "/tmp"
|
385
|
-
File.open("/tmp/.kitchen.yml", "wb") { |f| f.write
|
396
|
+
File.open("/tmp/.kitchen.yml", "wb") { |f| f.write "uhoh" }
|
386
397
|
|
387
398
|
err = proc { loader.read }.must_raise Kitchen::UserError
|
388
399
|
err.message.must_match Regexp.new(
|
@@ -398,7 +409,7 @@ describe Kitchen::Loader::YAML do
|
|
398
409
|
|
399
410
|
it "raises a UserError if kitchen.local.yml cannot be parsed" do
|
400
411
|
FileUtils.mkdir_p "/tmp"
|
401
|
-
File.open("/tmp/.kitchen.local.yml", "wb") { |f| f.write
|
412
|
+
File.open("/tmp/.kitchen.local.yml", "wb") { |f| f.write "&*%^*" }
|
402
413
|
stub_yaml!(".kitchen.yml", Hash.new)
|
403
414
|
|
404
415
|
proc { loader.read }.must_raise Kitchen::UserError
|
@@ -407,19 +418,19 @@ describe Kitchen::Loader::YAML do
|
|
407
418
|
it "evaluates kitchen.yml through erb before loading by default" do
|
408
419
|
FileUtils.mkdir_p "/tmp"
|
409
420
|
File.open("/tmp/.kitchen.yml", "wb") do |f|
|
410
|
-
f.write <<-'YAML'.gsub(/^ {10}/,
|
421
|
+
f.write <<-'YAML'.gsub(/^ {10}/, "")
|
411
422
|
---
|
412
423
|
name: <%= "AHH".downcase + "choo" %>
|
413
424
|
YAML
|
414
425
|
end
|
415
426
|
|
416
|
-
loader.read.must_equal(
|
427
|
+
loader.read.must_equal(:name => "ahhchoo")
|
417
428
|
end
|
418
429
|
|
419
430
|
it "raises a UserError if there is an ERB processing error" do
|
420
431
|
FileUtils.mkdir_p "/tmp"
|
421
432
|
File.open("/tmp/.kitchen.yml", "wb") do |f|
|
422
|
-
f.write <<-'YAML'.gsub(/^ {10}/,
|
433
|
+
f.write <<-'YAML'.gsub(/^ {10}/, "")
|
423
434
|
---
|
424
435
|
<%= poop %>: yep
|
425
436
|
YAML
|
@@ -433,75 +444,75 @@ describe Kitchen::Loader::YAML do
|
|
433
444
|
it "evaluates kitchen.local.yml through erb before loading by default" do
|
434
445
|
FileUtils.mkdir_p "/tmp"
|
435
446
|
File.open("/tmp/.kitchen.local.yml", "wb") do |f|
|
436
|
-
f.write <<-'YAML'.gsub(/^ {10}/,
|
447
|
+
f.write <<-'YAML'.gsub(/^ {10}/, "")
|
437
448
|
---
|
438
449
|
<% %w{noodle mushroom}.each do |kind| %>
|
439
450
|
<%= kind %>: soup
|
440
451
|
<% end %>
|
441
452
|
YAML
|
442
453
|
end
|
443
|
-
stub_yaml!(".kitchen.yml",
|
454
|
+
stub_yaml!(".kitchen.yml", "spinach" => "salad")
|
444
455
|
|
445
|
-
loader.read.must_equal(
|
446
|
-
:spinach =>
|
447
|
-
:noodle =>
|
448
|
-
:mushroom =>
|
449
|
-
|
456
|
+
loader.read.must_equal(
|
457
|
+
:spinach => "salad",
|
458
|
+
:noodle => "soup",
|
459
|
+
:mushroom => "soup"
|
460
|
+
)
|
450
461
|
end
|
451
462
|
|
452
463
|
it "skips evaluating kitchen.yml through erb if disabled" do
|
453
464
|
loader = Kitchen::Loader::YAML.new(
|
454
|
-
:project_config =>
|
465
|
+
:project_config => "/tmp/.kitchen.yml", :process_erb => false)
|
455
466
|
FileUtils.mkdir_p "/tmp"
|
456
467
|
File.open("/tmp/.kitchen.yml", "wb") do |f|
|
457
|
-
f.write <<-'YAML'.gsub(/^ {10}/,
|
468
|
+
f.write <<-'YAML'.gsub(/^ {10}/, "")
|
458
469
|
---
|
459
470
|
name: <%= "AHH".downcase %>
|
460
471
|
YAML
|
461
472
|
end
|
462
473
|
|
463
|
-
loader.read.must_equal(
|
474
|
+
loader.read.must_equal(:name => '<%= "AHH".downcase %>')
|
464
475
|
end
|
465
476
|
|
466
477
|
it "skips evaluating kitchen.local.yml through erb if disabled" do
|
467
478
|
loader = Kitchen::Loader::YAML.new(
|
468
|
-
:project_config =>
|
479
|
+
:project_config => "/tmp/.kitchen.yml", :process_erb => false)
|
469
480
|
FileUtils.mkdir_p "/tmp"
|
470
481
|
File.open("/tmp/.kitchen.local.yml", "wb") do |f|
|
471
|
-
f.write <<-'YAML'.gsub(/^ {10}/,
|
482
|
+
f.write <<-'YAML'.gsub(/^ {10}/, "")
|
472
483
|
---
|
473
484
|
name: <%= "AHH".downcase %>
|
474
485
|
YAML
|
475
486
|
end
|
476
487
|
stub_yaml!(".kitchen.yml", Hash.new)
|
477
488
|
|
478
|
-
loader.read.must_equal(
|
489
|
+
loader.read.must_equal(:name => '<%= "AHH".downcase %>')
|
479
490
|
end
|
480
491
|
|
481
492
|
it "skips kitchen.local.yml if disabled" do
|
482
493
|
loader = Kitchen::Loader::YAML.new(
|
483
|
-
:project_config =>
|
484
|
-
stub_yaml!(".kitchen.yml",
|
485
|
-
|
486
|
-
|
487
|
-
stub_yaml!(".kitchen.local.yml",
|
488
|
-
|
489
|
-
|
494
|
+
:project_config => "/tmp/.kitchen.yml", :process_local => false)
|
495
|
+
stub_yaml!(".kitchen.yml",
|
496
|
+
"a" => "b"
|
497
|
+
)
|
498
|
+
stub_yaml!(".kitchen.local.yml",
|
499
|
+
"superawesomesauceadditions" => "enabled, yo"
|
500
|
+
)
|
490
501
|
|
491
|
-
loader.read.must_equal(
|
502
|
+
loader.read.must_equal(:a => "b")
|
492
503
|
end
|
493
504
|
|
494
505
|
it "skips the global config if disabled" do
|
495
506
|
loader = Kitchen::Loader::YAML.new(
|
496
|
-
:project_config =>
|
497
|
-
stub_yaml!(".kitchen.yml",
|
498
|
-
|
499
|
-
|
500
|
-
stub_global!(
|
501
|
-
|
502
|
-
|
507
|
+
:project_config => "/tmp/.kitchen.yml", :process_global => false)
|
508
|
+
stub_yaml!(".kitchen.yml",
|
509
|
+
"a" => "b"
|
510
|
+
)
|
511
|
+
stub_global!(
|
512
|
+
"superawesomesauceadditions" => "enabled, yo"
|
513
|
+
)
|
503
514
|
|
504
|
-
loader.read.must_equal(
|
515
|
+
loader.read.must_equal(:a => "b")
|
505
516
|
end
|
506
517
|
end
|
507
518
|
|
@@ -522,7 +533,7 @@ describe Kitchen::Loader::YAML do
|
|
522
533
|
it "contains erb processing information when false" do
|
523
534
|
stub_yaml!(Hash.new)
|
524
535
|
loader = Kitchen::Loader::YAML.new(
|
525
|
-
:project_config =>
|
536
|
+
:project_config => "/tmp/.kitchen.yml", :process_erb => false)
|
526
537
|
|
527
538
|
loader.diagnose[:process_erb].must_equal false
|
528
539
|
end
|
@@ -536,7 +547,7 @@ describe Kitchen::Loader::YAML do
|
|
536
547
|
it "contains local processing information when false" do
|
537
548
|
stub_yaml!(Hash.new)
|
538
549
|
loader = Kitchen::Loader::YAML.new(
|
539
|
-
:project_config =>
|
550
|
+
:project_config => "/tmp/.kitchen.yml", :process_local => false)
|
540
551
|
|
541
552
|
loader.diagnose[:process_local].must_equal false
|
542
553
|
end
|
@@ -550,7 +561,7 @@ describe Kitchen::Loader::YAML do
|
|
550
561
|
it "contains global processing information when false" do
|
551
562
|
stub_yaml!(Hash.new)
|
552
563
|
loader = Kitchen::Loader::YAML.new(
|
553
|
-
:project_config =>
|
564
|
+
:project_config => "/tmp/.kitchen.yml", :process_global => false)
|
554
565
|
|
555
566
|
loader.diagnose[:process_global].must_equal false
|
556
567
|
end
|
@@ -558,18 +569,18 @@ describe Kitchen::Loader::YAML do
|
|
558
569
|
describe "for yaml files" do
|
559
570
|
|
560
571
|
before do
|
561
|
-
stub_yaml!(".kitchen.yml",
|
572
|
+
stub_yaml!(".kitchen.yml",
|
562
573
|
"from_project" => "project",
|
563
574
|
"common" => { "p" => "pretty" }
|
564
|
-
|
565
|
-
stub_yaml!(".kitchen.local.yml",
|
575
|
+
)
|
576
|
+
stub_yaml!(".kitchen.local.yml",
|
566
577
|
"from_local" => "local",
|
567
578
|
"common" => { "l" => "looky" }
|
568
|
-
|
569
|
-
stub_global!(
|
579
|
+
)
|
580
|
+
stub_global!(
|
570
581
|
"from_global" => "global",
|
571
582
|
"common" => { "g" => "goody" }
|
572
|
-
|
583
|
+
)
|
573
584
|
end
|
574
585
|
|
575
586
|
it "global config contains a filename" do
|
@@ -578,10 +589,10 @@ describe Kitchen::Loader::YAML do
|
|
578
589
|
end
|
579
590
|
|
580
591
|
it "global config contains raw data" do
|
581
|
-
loader.diagnose[:global_config][:raw_data].must_equal(
|
592
|
+
loader.diagnose[:global_config][:raw_data].must_equal(
|
582
593
|
"from_global" => "global",
|
583
594
|
"common" => { "g" => "goody" }
|
584
|
-
|
595
|
+
)
|
585
596
|
end
|
586
597
|
|
587
598
|
it "project config contains a filename" do
|
@@ -590,10 +601,10 @@ describe Kitchen::Loader::YAML do
|
|
590
601
|
end
|
591
602
|
|
592
603
|
it "project config contains raw data" do
|
593
|
-
loader.diagnose[:project_config][:raw_data].must_equal(
|
604
|
+
loader.diagnose[:project_config][:raw_data].must_equal(
|
594
605
|
"from_project" => "project",
|
595
606
|
"common" => { "p" => "pretty" }
|
596
|
-
|
607
|
+
)
|
597
608
|
end
|
598
609
|
|
599
610
|
it "local config contains a filename" do
|
@@ -602,10 +613,10 @@ describe Kitchen::Loader::YAML do
|
|
602
613
|
end
|
603
614
|
|
604
615
|
it "local config contains raw data" do
|
605
|
-
loader.diagnose[:local_config][:raw_data].must_equal(
|
616
|
+
loader.diagnose[:local_config][:raw_data].must_equal(
|
606
617
|
"from_local" => "local",
|
607
618
|
"common" => { "l" => "looky" }
|
608
|
-
|
619
|
+
)
|
609
620
|
end
|
610
621
|
|
611
622
|
it "combined config contains a nil filename" do
|
@@ -614,7 +625,7 @@ describe Kitchen::Loader::YAML do
|
|
614
625
|
end
|
615
626
|
|
616
627
|
it "combined config contains raw data" do
|
617
|
-
loader.diagnose[:combined_config][:raw_data].must_equal(
|
628
|
+
loader.diagnose[:combined_config][:raw_data].must_equal(
|
618
629
|
"from_global" => "global",
|
619
630
|
"from_project" => "project",
|
620
631
|
"from_local" => "local",
|
@@ -623,7 +634,7 @@ describe Kitchen::Loader::YAML do
|
|
623
634
|
"p" => "pretty",
|
624
635
|
"l" => "looky"
|
625
636
|
}
|
626
|
-
|
637
|
+
)
|
627
638
|
end
|
628
639
|
|
629
640
|
describe "for global on error" do
|
@@ -631,7 +642,7 @@ describe Kitchen::Loader::YAML do
|
|
631
642
|
before do
|
632
643
|
FileUtils.mkdir_p(File.join(ENV["HOME"], ".kitchen"))
|
633
644
|
File.open(File.join(ENV["HOME"], ".kitchen/config.yml"), "wb") do |f|
|
634
|
-
f.write
|
645
|
+
f.write "&*%^*"
|
635
646
|
end
|
636
647
|
end
|
637
648
|
|
@@ -660,7 +671,7 @@ describe Kitchen::Loader::YAML do
|
|
660
671
|
|
661
672
|
before do
|
662
673
|
File.open("/tmp/.kitchen.yml", "wb") do |f|
|
663
|
-
f.write
|
674
|
+
f.write "&*%^*"
|
664
675
|
end
|
665
676
|
end
|
666
677
|
|
@@ -689,7 +700,7 @@ describe Kitchen::Loader::YAML do
|
|
689
700
|
|
690
701
|
before do
|
691
702
|
File.open("/tmp/.kitchen.local.yml", "wb") do |f|
|
692
|
-
f.write
|
703
|
+
f.write "&*%^*"
|
693
704
|
end
|
694
705
|
end
|
695
706
|
|
@@ -718,7 +729,7 @@ describe Kitchen::Loader::YAML do
|
|
718
729
|
|
719
730
|
before do
|
720
731
|
File.open("/tmp/.kitchen.yml", "wb") do |f|
|
721
|
-
f.write
|
732
|
+
f.write "&*%^*"
|
722
733
|
end
|
723
734
|
end
|
724
735
|
|