test-kitchen 1.23.3 → 1.23.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (254) hide show
  1. checksums.yaml +4 -4
  2. data/lib/kitchen/version.rb +1 -1
  3. data/support/chef-client-zero.rb +1 -1
  4. metadata +5 -324
  5. data/.gitattributes +0 -3
  6. data/.github/ISSUE_TEMPLATE.md +0 -56
  7. data/.github/lock.yml +0 -1
  8. data/.gitignore +0 -38
  9. data/.gitmodules +0 -0
  10. data/.kitchen.appveyor.yml +0 -25
  11. data/.kitchen.dokken.yml +0 -31
  12. data/.kitchen.proxy.yml +0 -27
  13. data/.rubocop.yml +0 -5
  14. data/.travis.yml +0 -57
  15. data/.yardopts +0 -3
  16. data/Berksfile +0 -3
  17. data/CHANGELOG.md +0 -1510
  18. data/CONTRIBUTING.md +0 -14
  19. data/ECOSYSTEM.md +0 -93
  20. data/Gemfile +0 -40
  21. data/Gemfile.proxy_tests +0 -4
  22. data/Guardfile +0 -42
  23. data/MAINTAINERS.md +0 -29
  24. data/README.md +0 -138
  25. data/RELEASE_NOTES.md +0 -167
  26. data/Rakefile +0 -77
  27. data/appveyor.yml +0 -47
  28. data/docs/CONTRIBUTING.md +0 -8
  29. data/docs/LICENSE +0 -22
  30. data/docs/README.md +0 -78
  31. data/docs/archetypes/default.md +0 -6
  32. data/docs/config.toml +0 -36
  33. data/docs/content/docs/_index.md +0 -5
  34. data/docs/content/docs/drivers/_index.md +0 -27
  35. data/docs/content/docs/drivers/azurerm.md +0 -44
  36. data/docs/content/docs/drivers/vagrant.md +0 -39
  37. data/docs/content/docs/getting-started/00-introduction.md +0 -14
  38. data/docs/content/docs/getting-started/01-installing.md +0 -64
  39. data/docs/content/docs/getting-started/02-getting-help.md +0 -59
  40. data/docs/content/docs/getting-started/03-creating-cookbook.md +0 -46
  41. data/docs/content/docs/getting-started/04-kitchen-yml.md +0 -56
  42. data/docs/content/docs/getting-started/05-instances.md +0 -79
  43. data/docs/content/docs/getting-started/06-writing-recipe.md +0 -21
  44. data/docs/content/docs/getting-started/07-running-converge.md +0 -134
  45. data/docs/content/docs/getting-started/08-manually-verifying.md +0 -55
  46. data/docs/content/docs/getting-started/09-writing-test.md +0 -49
  47. data/docs/content/docs/getting-started/10-running-verify.md +0 -120
  48. data/docs/content/docs/getting-started/11-running-test.md +0 -168
  49. data/docs/content/docs/getting-started/12-adding-platform.md +0 -206
  50. data/docs/content/docs/getting-started/13-adding-feature.md +0 -30
  51. data/docs/content/docs/getting-started/14-adding-suite.md +0 -60
  52. data/docs/content/docs/getting-started/15-adding-test.md +0 -66
  53. data/docs/content/docs/getting-started/16-adding-recipe.md +0 -53
  54. data/docs/content/docs/getting-started/17-excluding-platforms.md +0 -101
  55. data/docs/content/docs/getting-started/18-next-steps.md +0 -23
  56. data/docs/content/docs/getting-started/_index.md +0 -5
  57. data/docs/content/docs/provisioners/_index.md +0 -36
  58. data/docs/content/docs/provisioners/chef.md +0 -69
  59. data/docs/content/docs/provisioners/shell.md +0 -31
  60. data/docs/content/docs/reference/_index.md +0 -5
  61. data/docs/content/docs/reference/configuration.md +0 -53
  62. data/docs/content/docs/reference/examples.md +0 -97
  63. data/docs/content/docs/reference/faq.md +0 -58
  64. data/docs/content/docs/reference/fixtures.md +0 -32
  65. data/docs/content/docs/reference/glossary.md +0 -34
  66. data/docs/content/docs/reference/lifecycle-hooks.md +0 -68
  67. data/docs/content/docs/reference/reboots.md +0 -24
  68. data/docs/content/docs/verifiers/_index.md +0 -14
  69. data/docs/content/docs/verifiers/inspec.md +0 -44
  70. data/docs/content/docs/verifiers/serverspec.md +0 -20
  71. data/docs/static/images/chef-logo.png +0 -0
  72. data/docs/static/images/chef-logo.svg +0 -1
  73. data/docs/static/images/github-banner.png +0 -0
  74. data/docs/static/images/github-banner.svg +0 -71
  75. data/docs/static/images/kitchen-logo.png +0 -0
  76. data/docs/static/images/logo-block.svg +0 -222
  77. data/docs/static/images/logo.png +0 -0
  78. data/docs/static/images/logos-group.png +0 -0
  79. data/docs/static/images/terminal-1.png +0 -0
  80. data/docs/static/images/terminal-1.svg +0 -589
  81. data/docs/static/images/terminal-2.png +0 -0
  82. data/docs/static/images/terminal-2.svg +0 -235
  83. data/docs/static/images/terminal-3.png +0 -0
  84. data/docs/static/images/terminal-3.svg +0 -439
  85. data/docs/static/index.html +0 -59
  86. data/docs/static/javascripts/all.js +0 -348
  87. data/docs/static/javascripts/vendor/foundation.min.js +0 -4
  88. data/docs/static/javascripts/vendor/jquery.min.js +0 -5
  89. data/docs/static/javascripts/vendor/what-input.js +0 -336
  90. data/docs/static/stylesheets/site.css +0 -4667
  91. data/docs/themes/kitchen/layouts/_default/baseof.html +0 -53
  92. data/docs/themes/kitchen/layouts/_default/list.html +0 -4
  93. data/docs/themes/kitchen/layouts/_default/redirect.html +0 -10
  94. data/docs/themes/kitchen/layouts/_default/single.html +0 -6
  95. data/docs/themes/kitchen/layouts/partials/core/head.html +0 -6
  96. data/docs/themes/kitchen/layouts/partials/kitchen/footer.html +0 -18
  97. data/docs/themes/kitchen/layouts/partials/kitchen/head.html +0 -4
  98. data/docs/themes/kitchen/layouts/partials/kitchen/header.html +0 -26
  99. data/docs/themes/kitchen/layouts/partials/search-docs.html +0 -3
  100. data/docs/themes/kitchen/layouts/partials/sidebar.html +0 -33
  101. data/docs/themes/kitchen/layouts/shortcodes/button.html +0 -1
  102. data/docs/themes/kitchen/layouts/shortcodes/codeblock.html +0 -8
  103. data/docs/themes/kitchen/layouts/shortcodes/cta.html +0 -5
  104. data/docs/themes/kitchen/layouts/shortcodes/danger.html +0 -1
  105. data/docs/themes/kitchen/layouts/shortcodes/example_fqdn.html +0 -1
  106. data/docs/themes/kitchen/layouts/shortcodes/info.html +0 -1
  107. data/docs/themes/kitchen/layouts/shortcodes/ol-styled.html +0 -3
  108. data/docs/themes/kitchen/layouts/shortcodes/success.html +0 -1
  109. data/docs/themes/kitchen/layouts/shortcodes/tip.html +0 -1
  110. data/docs/themes/kitchen/layouts/shortcodes/warning.html +0 -1
  111. data/docs/themes/kitchen/static/css/kitchen.css +0 -10
  112. data/docs/themes/kitchen/static/css/kitchen.css.map +0 -7
  113. data/docs/themes/kitchen/static/fonts/Muli-Bold.ttf +0 -0
  114. data/docs/themes/kitchen/static/fonts/Muli-Regular.ttf +0 -0
  115. data/docs/themes/kitchen/static/fonts/Muli-SemiBold.ttf +0 -0
  116. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.eot +0 -0
  117. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.svg +0 -1104
  118. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.ttf +0 -0
  119. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.woff +0 -0
  120. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.woff2 +0 -0
  121. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.eot +0 -0
  122. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.svg +0 -372
  123. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.ttf +0 -0
  124. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.woff +0 -0
  125. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.woff2 +0 -0
  126. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.eot +0 -0
  127. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.svg +0 -1896
  128. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.ttf +0 -0
  129. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.woff +0 -0
  130. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.woff2 +0 -0
  131. data/docs/themes/kitchen/static/images/chef-logo-light.svg +0 -36
  132. data/docs/themes/kitchen/static/images/chef-logo-white.svg +0 -38
  133. data/docs/themes/kitchen/static/images/chef-logo.svg +0 -37
  134. data/docs/themes/kitchen/static/images/favicon.ico +0 -0
  135. data/docs/themes/kitchen/static/js/scripts-all.js +0 -7
  136. data/docs/themes/kitchen/static/js/source/chef-hugo.js +0 -116
  137. data/docs/themes/kitchen/static/js/source/omnitruck.js +0 -82
  138. data/docs/themes/kitchen/static/js/source/segment.js +0 -52
  139. data/docs/themes/kitchen/static/sass/_buttons.scss +0 -161
  140. data/docs/themes/kitchen/static/sass/_core.scss +0 -24
  141. data/docs/themes/kitchen/static/sass/_forms.scss +0 -14
  142. data/docs/themes/kitchen/static/sass/_mixins.scss +0 -133
  143. data/docs/themes/kitchen/static/sass/_typography.scss +0 -34
  144. data/docs/themes/kitchen/static/sass/_variables.scss +0 -82
  145. data/docs/themes/kitchen/static/sass/kitchen.scss +0 -7
  146. data/docs/themes/kitchen/static/sass/kitchen/_footer.scss +0 -50
  147. data/docs/themes/kitchen/static/sass/kitchen/_header.scss +0 -187
  148. data/docs/themes/kitchen/static/sass/kitchen/_homepage.scss +0 -27
  149. data/docs/themes/kitchen/static/sass/kitchen/_utility-bar.scss +0 -173
  150. data/docs/themes/kitchen/static/sass/partials/_alerts.scss +0 -32
  151. data/docs/themes/kitchen/static/sass/partials/_bg.scss +0 -19
  152. data/docs/themes/kitchen/static/sass/partials/_blurbs.scss +0 -25
  153. data/docs/themes/kitchen/static/sass/partials/_callout.scss +0 -15
  154. data/docs/themes/kitchen/static/sass/partials/_cards.scss +0 -54
  155. data/docs/themes/kitchen/static/sass/partials/_dropdown.scss +0 -77
  156. data/docs/themes/kitchen/static/sass/partials/_grid.scss +0 -87
  157. data/docs/themes/kitchen/static/sass/partials/_padding.scss +0 -73
  158. data/docs/themes/kitchen/static/sass/partials/_sidebar.scss +0 -71
  159. data/docs/themes/kitchen/static/sass/partials/_tabs.scss +0 -125
  160. data/docs/themes/kitchen/static/sass/typography/_chroma.scss +0 -366
  161. data/docs/themes/kitchen/static/sass/typography/_code.scss +0 -72
  162. data/docs/themes/kitchen/static/sass/typography/_headers.scss +0 -90
  163. data/docs/themes/kitchen/static/sass/typography/_links.scss +0 -127
  164. data/docs/themes/kitchen/static/sass/typography/_lists.scss +0 -155
  165. data/docs/themes/kitchen/static/sass/typography/_prose.scss +0 -29
  166. data/docs/themes/kitchen/static/sass/typography/_text.scss +0 -221
  167. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_animated.scss +0 -20
  168. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_bordered-pulled.scss +0 -20
  169. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_core.scss +0 -16
  170. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_fixed-width.scss +0 -6
  171. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_icons.scss +0 -992
  172. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_larger.scss +0 -23
  173. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_list.scss +0 -18
  174. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_mixins.scss +0 -57
  175. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_rotated-flipped.scss +0 -23
  176. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_screen-reader.scss +0 -5
  177. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_stacked.scss +0 -31
  178. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_variables.scss +0 -1005
  179. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-brands.scss +0 -21
  180. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-regular.scss +0 -22
  181. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-solid.scss +0 -23
  182. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fontawesome.scss +0 -16
  183. data/docs/themes/kitchen/theme.toml +0 -8
  184. data/features/kitchen_action_commands.feature +0 -164
  185. data/features/kitchen_command.feature +0 -16
  186. data/features/kitchen_console_command.feature +0 -35
  187. data/features/kitchen_defaults.feature +0 -38
  188. data/features/kitchen_diagnose_command.feature +0 -96
  189. data/features/kitchen_help_command.feature +0 -16
  190. data/features/kitchen_init_command.feature +0 -254
  191. data/features/kitchen_list_command.feature +0 -140
  192. data/features/kitchen_login_command.feature +0 -62
  193. data/features/kitchen_sink_command.feature +0 -30
  194. data/features/kitchen_test_command.feature +0 -88
  195. data/features/step_definitions/gem_steps.rb +0 -24
  196. data/features/step_definitions/git_steps.rb +0 -5
  197. data/features/step_definitions/output_steps.rb +0 -5
  198. data/features/support/env.rb +0 -74
  199. data/spec/kitchen/base64_stream_spec.rb +0 -74
  200. data/spec/kitchen/cli_spec.rb +0 -54
  201. data/spec/kitchen/collection_spec.rb +0 -76
  202. data/spec/kitchen/color_spec.rb +0 -51
  203. data/spec/kitchen/config_spec.rb +0 -434
  204. data/spec/kitchen/configurable_spec.rb +0 -1113
  205. data/spec/kitchen/data_munger_spec.rb +0 -2800
  206. data/spec/kitchen/diagnostic_spec.rb +0 -128
  207. data/spec/kitchen/driver/base_spec.rb +0 -132
  208. data/spec/kitchen/driver/dummy_spec.rb +0 -193
  209. data/spec/kitchen/driver/exec_spec.rb +0 -75
  210. data/spec/kitchen/driver/proxy_spec.rb +0 -127
  211. data/spec/kitchen/driver/ssh_base_spec.rb +0 -1136
  212. data/spec/kitchen/driver_spec.rb +0 -106
  213. data/spec/kitchen/errors_spec.rb +0 -317
  214. data/spec/kitchen/instance_spec.rb +0 -1372
  215. data/spec/kitchen/lazy_hash_spec.rb +0 -113
  216. data/spec/kitchen/lifecycle_hooks_spec.rb +0 -171
  217. data/spec/kitchen/loader/yaml_spec.rb +0 -787
  218. data/spec/kitchen/logger_spec.rb +0 -425
  219. data/spec/kitchen/logging_spec.rb +0 -56
  220. data/spec/kitchen/login_command_spec.rb +0 -67
  221. data/spec/kitchen/metadata_chopper_spec.rb +0 -79
  222. data/spec/kitchen/platform_spec.rb +0 -88
  223. data/spec/kitchen/provisioner/base_spec.rb +0 -393
  224. data/spec/kitchen/provisioner/chef/policyfile_spec.rb +0 -140
  225. data/spec/kitchen/provisioner/chef_apply_spec.rb +0 -131
  226. data/spec/kitchen/provisioner/chef_base_spec.rb +0 -1565
  227. data/spec/kitchen/provisioner/chef_solo_spec.rb +0 -602
  228. data/spec/kitchen/provisioner/chef_zero_spec.rb +0 -1013
  229. data/spec/kitchen/provisioner/dummy_spec.rb +0 -96
  230. data/spec/kitchen/provisioner/shell_spec.rb +0 -623
  231. data/spec/kitchen/provisioner_spec.rb +0 -101
  232. data/spec/kitchen/shell_out_spec.rb +0 -146
  233. data/spec/kitchen/ssh_spec.rb +0 -584
  234. data/spec/kitchen/state_file_spec.rb +0 -122
  235. data/spec/kitchen/suite_spec.rb +0 -61
  236. data/spec/kitchen/transport/base_spec.rb +0 -140
  237. data/spec/kitchen/transport/exec_spec.rb +0 -79
  238. data/spec/kitchen/transport/ssh_spec.rb +0 -1317
  239. data/spec/kitchen/transport/winrm_spec.rb +0 -1320
  240. data/spec/kitchen/transport_spec.rb +0 -106
  241. data/spec/kitchen/util_spec.rb +0 -250
  242. data/spec/kitchen/verifier/base_spec.rb +0 -346
  243. data/spec/kitchen/verifier/busser_spec.rb +0 -580
  244. data/spec/kitchen/verifier/dummy_spec.rb +0 -96
  245. data/spec/kitchen/verifier/shell_spec.rb +0 -157
  246. data/spec/kitchen/verifier_spec.rb +0 -114
  247. data/spec/kitchen_spec.rb +0 -112
  248. data/spec/spec_helper.rb +0 -110
  249. data/spec/support/powershell_max_size_spec.rb +0 -39
  250. data/test-kitchen.gemspec +0 -49
  251. data/test/cookbooks/test_cookbook/metadata.rb +0 -6
  252. data/test/cookbooks/test_cookbook/recipes/default.rb +0 -1
  253. data/test/integration/default/default_spec.rb +0 -3
  254. data/testing_windows.md +0 -38
@@ -1,434 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
- # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
- #
5
- # Copyright (C) 2012, Fletcher Nichol
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- require_relative "../spec_helper"
20
-
21
- require "kitchen"
22
- require "kitchen/logging"
23
- require "kitchen/collection"
24
- require "kitchen/config"
25
- require "kitchen/driver"
26
- require "kitchen/instance"
27
- require "kitchen/platform"
28
- require "kitchen/provisioner"
29
- require "kitchen/suite"
30
- require "kitchen/transport"
31
- require "kitchen/util"
32
- require "kitchen/verifier"
33
-
34
- module Kitchen
35
- class DummyLoader
36
- attr_writer :data
37
-
38
- def initialize
39
- @data = {}
40
- end
41
-
42
- def read
43
- @data
44
- end
45
- end
46
- end
47
-
48
- describe Kitchen::Config do
49
- # Explicitly enable tty to test colorize default option later
50
- before do
51
- Kitchen.stubs(:tty?).returns(true)
52
- end
53
-
54
- let(:loader) { Kitchen::DummyLoader.new }
55
- let(:config) { Kitchen::Config.new(opts) }
56
-
57
- let(:opts) do
58
- {
59
- loader: loader,
60
- kitchen_root: "/tmp/that/place",
61
- log_root: "/tmp/logs",
62
- test_base_path: "/testing/yo",
63
- log_level: :debug,
64
- log_overwrite: false,
65
- colorize: false,
66
- debug: true,
67
- }
68
- end
69
-
70
- let(:default_kitchen_config) do
71
- {
72
- defaults: {
73
- driver: "dummy",
74
- provisioner: "chef_solo",
75
- transport: "ssh",
76
- verifier: "busser",
77
- },
78
- kitchen_root: "/tmp/that/place",
79
- test_base_path: "/testing/yo",
80
- log_level: :debug,
81
- log_overwrite: false,
82
- colorize: false,
83
- }
84
- end
85
-
86
- describe "#loader" do
87
- it "returns its loader" do
88
- config.loader.must_equal loader
89
- end
90
-
91
- it "creates a Kitchen::Loader::YAML loader by default" do
92
- opts.delete(:loader)
93
-
94
- config.loader.must_be_kind_of Kitchen::Loader::YAML
95
- end
96
- end
97
-
98
- describe "#kitchen_root" do
99
- it "returns its kitchen root" do
100
- config.kitchen_root.must_equal "/tmp/that/place"
101
- end
102
-
103
- it "uses Dir.pwd by default" do
104
- opts.delete(:kitchen_root)
105
-
106
- config.kitchen_root.must_equal Dir.pwd
107
- end
108
- end
109
-
110
- describe "#log_root" do
111
- it "returns its log root" do
112
- config.log_root.must_equal "/tmp/logs"
113
- end
114
-
115
- it "calculates a default log root using kitchen_root" do
116
- opts.delete(:log_root)
117
-
118
- config.log_root.must_equal "/tmp/that/place/.kitchen/logs"
119
- end
120
- end
121
-
122
- describe "#test_base_path" do
123
- it "returns its base test path" do
124
- config.test_base_path.must_equal "/testing/yo"
125
- end
126
-
127
- it "calculates a default base using kitchen_root" do
128
- opts.delete(:test_base_path)
129
-
130
- config.test_base_path.must_equal "/tmp/that/place/test/integration"
131
- end
132
- end
133
-
134
- describe "#log_level" do
135
- it "returns its log level" do
136
- config.log_level.must_equal :debug
137
- end
138
-
139
- it "uses :info by default" do
140
- opts.delete(:log_level)
141
-
142
- config.log_level.must_equal :info
143
- end
144
- end
145
-
146
- describe "#log_overwrite" do
147
- it "returns its log level" do
148
- config.log_overwrite.must_equal false
149
- end
150
-
151
- it "uses :info by default" do
152
- opts.delete(:log_overwrite)
153
-
154
- config.log_overwrite.must_equal true
155
- end
156
- end
157
-
158
- describe "#colorize" do
159
- it "returns its colorize" do
160
- config.colorize.must_equal false
161
- end
162
-
163
- it "uses true by default" do
164
- opts.delete(:colorize)
165
-
166
- config.colorize.must_equal true
167
- end
168
- end
169
-
170
- describe "#debug" do
171
- it "returns its debug" do
172
- config.debug.must_equal true
173
- end
174
-
175
- it "uses false by default" do
176
- opts.delete(:debug)
177
-
178
- config.debug.must_equal false
179
- end
180
- end
181
-
182
- describe "#platforms" do
183
- before do
184
- Kitchen::DataMunger.stubs(:new).returns(munger)
185
- Kitchen::Platform.stubs(:new).returns("platform")
186
- end
187
-
188
- let(:munger) do
189
- stub(
190
- platform_data: [{ one: "a" }, { two: "b" }]
191
- )
192
- end
193
-
194
- it "loader loads data" do
195
- loader.expects(:read).returns({})
196
-
197
- config.platforms
198
- end
199
-
200
- it "constructs a munger with loader data and defaults" do
201
- loader.stubs(:read).returns("datum")
202
-
203
- Kitchen::DataMunger.expects(:new).with do |data, kitchen_config|
204
- data.must_equal "datum"
205
- kitchen_config.is_a?(Hash).must_equal true
206
- end.returns(munger)
207
-
208
- config.platforms
209
- end
210
-
211
- it "platform_data is called on munger" do
212
- munger.expects(:platform_data).returns([])
213
-
214
- config.platforms
215
- end
216
-
217
- it "contructs Platform objects" do
218
- Kitchen::Platform.expects(:new).with(one: "a")
219
- Kitchen::Platform.expects(:new).with(two: "b")
220
-
221
- config.platforms
222
- end
223
-
224
- it "returns a Collection of platforms" do
225
- Kitchen::Platform.stubs(:new)
226
- .with(one: "a").returns(stub(name: "one"))
227
- Kitchen::Platform.stubs(:new)
228
- .with(two: "b").returns(stub(name: "two"))
229
-
230
- config.platforms.as_names.must_equal %w{one two}
231
- end
232
- end
233
-
234
- describe "#suites" do
235
- before do
236
- Kitchen::DataMunger.stubs(:new).returns(munger)
237
- Kitchen::Suite.stubs(:new).returns("suite")
238
- end
239
-
240
- let(:munger) do
241
- stub(
242
- suite_data: [{ one: "a" }, { two: "b" }]
243
- )
244
- end
245
-
246
- it "loader loads data" do
247
- loader.expects(:read).returns({})
248
-
249
- config.suites
250
- end
251
-
252
- it "constucts a munger with loader data and defaults" do
253
- loader.stubs(:read).returns("datum")
254
-
255
- Kitchen::DataMunger.expects(:new).with do |data, kitchen_config|
256
- data.must_equal "datum"
257
- kitchen_config.is_a?(Hash).must_equal true
258
- end.returns(munger)
259
-
260
- config.suites
261
- end
262
-
263
- it "platform_data is called on munger" do
264
- munger.expects(:suite_data).returns([])
265
-
266
- config.suites
267
- end
268
-
269
- it "contructs Suite objects" do
270
- Kitchen::Suite.expects(:new).with(one: "a")
271
- Kitchen::Suite.expects(:new).with(two: "b")
272
-
273
- config.suites
274
- end
275
-
276
- it "returns a Collection of suites" do
277
- Kitchen::Suite.stubs(:new)
278
- .with(one: "a").returns(stub(name: "one"))
279
- Kitchen::Suite.stubs(:new)
280
- .with(two: "b").returns(stub(name: "two"))
281
-
282
- config.suites.as_names.must_equal %w{one two}
283
- end
284
- end
285
-
286
- describe "#instances" do
287
- let(:platforms) do
288
- [stub(name: "unax")]
289
- end
290
-
291
- let(:suites) do
292
- [stub(name: "tiny", includes: [], excludes: [])]
293
- end
294
-
295
- let(:munger) do
296
- stub(
297
- driver_data_for: { "junk" => true },
298
- lifecycle_hooks_data_for: { "junk" => true },
299
- provisioner_data_for: { "junk" => true },
300
- transport_data_for: { "junk" => true },
301
- verifier_data_for: { "junk" => true }
302
- )
303
- end
304
-
305
- before do
306
- Kitchen::Instance.stubs(:new).returns("instance")
307
- Kitchen::Driver.stubs(:for_plugin).returns("driver")
308
- Kitchen::Provisioner.stubs(:for_plugin).returns("provisioner")
309
- Kitchen::Transport.stubs(:for_plugin).returns("transport")
310
- Kitchen::Verifier.stubs(:for_plugin).returns("verifier")
311
- Kitchen::Logger.stubs(:new).returns("logger")
312
- Kitchen::StateFile.stubs(:new).returns("state_file")
313
- Kitchen::LifecycleHooks.stubs(:new).returns("lifecycle_hooks")
314
-
315
- Kitchen::DataMunger.stubs(:new).returns(munger)
316
- config.stubs(:platforms).returns(platforms)
317
- config.stubs(:suites).returns(suites)
318
- end
319
-
320
- it "constructs a Driver object" do
321
- munger.expects(:driver_data_for).with("tiny", "unax")
322
- .returns(name: "drivey", datum: "lots")
323
- Kitchen::Driver.unstub(:for_plugin)
324
- Kitchen::Driver.expects(:for_plugin)
325
- .with("drivey", name: "drivey", datum: "lots")
326
-
327
- config.instances
328
- end
329
-
330
- it "constructs a Provisioner object" do
331
- munger.expects(:provisioner_data_for).with("tiny", "unax")
332
- .returns(name: "provey", datum: "lots")
333
- Kitchen::Provisioner.unstub(:for_plugin)
334
- Kitchen::Provisioner.expects(:for_plugin)
335
- .with("provey", name: "provey", datum: "lots")
336
-
337
- config.instances
338
- end
339
-
340
- it "constructs a Transport object" do
341
- munger.expects(:transport_data_for).with("tiny", "unax")
342
- .returns(name: "transey", datum: "lots")
343
- Kitchen::Transport.unstub(:for_plugin)
344
- Kitchen::Transport.expects(:for_plugin)
345
- .with("transey", name: "transey", datum: "lots")
346
-
347
- config.instances
348
- end
349
-
350
- it "constructs a Verifier object" do
351
- munger.expects(:verifier_data_for).with("tiny", "unax")
352
- .returns(name: "vervey", datum: "lots")
353
- Kitchen::Verifier.unstub(:for_plugin)
354
- Kitchen::Verifier.expects(:for_plugin)
355
- .with("vervey", name: "vervey", datum: "lots")
356
-
357
- config.instances
358
- end
359
-
360
- it "constructs a Logger object" do
361
- Kitchen::Logger.unstub(:new)
362
- Kitchen::Logger.expects(:new).with(
363
- stdout: STDOUT,
364
- color: :cyan,
365
- logdev: "/tmp/logs/tiny-unax.log",
366
- log_overwrite: false,
367
- level: 0,
368
- progname: "tiny-unax",
369
- colorize: false
370
- )
371
-
372
- config.instances
373
- end
374
-
375
- it "constructs a StateFile object" do
376
- Kitchen::StateFile.unstub(:new)
377
- Kitchen::StateFile.expects(:new).with("/tmp/that/place", "tiny-unax")
378
-
379
- config.instances
380
- end
381
-
382
- it "constructs an Instance object from all built objects" do
383
- Kitchen::Instance.unstub(:new)
384
-
385
- Kitchen::Instance.expects(:new).with(
386
- driver: "driver",
387
- logger: "logger",
388
- suite: suites.first,
389
- lifecycle_hooks: "lifecycle_hooks",
390
- platform: platforms.first,
391
- provisioner: "provisioner",
392
- transport: "transport",
393
- verifier: "verifier",
394
- state_file: "state_file"
395
- )
396
-
397
- config.instances
398
- end
399
- end
400
-
401
- describe "using Suite#includes" do
402
- it "selects only platforms in a suite's includes array" do
403
- config.stubs(:platforms).returns([
404
- stub(name: "good"),
405
- stub(name: "nope"),
406
- stub(name: "one"),
407
- ])
408
- config.stubs(:suites).returns([
409
- stub(name: "selecta", includes: %w{good one}, excludes: []),
410
- stub(name: "allem", includes: [], excludes: []),
411
- ])
412
-
413
- config.instances.as_names.must_equal [
414
- "selecta-good", "selecta-one", "allem-good", "allem-nope", "allem-one"]
415
- end
416
- end
417
-
418
- describe "using Suite#excludes" do
419
- it "selects only platforms in a suite's includes array" do
420
- config.stubs(:platforms).returns([
421
- stub(name: "good"),
422
- stub(name: "nope"),
423
- stub(name: "one"),
424
- ])
425
- config.stubs(:suites).returns([
426
- stub(name: "selecta", includes: [], excludes: ["nope"]),
427
- stub(name: "allem", includes: [], excludes: []),
428
- ])
429
-
430
- config.instances.as_names.must_equal [
431
- "selecta-good", "selecta-one", "allem-good", "allem-nope", "allem-one"]
432
- end
433
- end
434
- end
@@ -1,1113 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
- # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
- #
5
- # Copyright (C) 2014, Fletcher Nichol
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- require_relative "../spec_helper"
20
- require "stringio"
21
-
22
- require "kitchen"
23
- require "kitchen/errors"
24
- require "kitchen/configurable"
25
-
26
- module Kitchen
27
- module Thing
28
- class Tiny
29
- include Kitchen::Configurable
30
-
31
- attr_reader :instance
32
-
33
- def initialize(config = {})
34
- init_config(config)
35
- @instance = config[:instance]
36
- end
37
- end
38
-
39
- class Versioned < Tiny
40
- plugin_version "1.8.17"
41
- end
42
-
43
- class StaticDefaults
44
- include Kitchen::Configurable
45
-
46
- default_config :beans, "kidney"
47
- default_config :tunables, "flimflam" => "positate"
48
- default_config :edible, true
49
- default_config :fetch_command, "curl"
50
- default_config :success_path, "./success"
51
- default_config :bunch_of_paths, %w{./a ./b ./c}
52
- default_config :beans_url do |subject|
53
- "http://gim.me/#{subject[:beans]}"
54
- end
55
- default_config :command do |subject|
56
- "#{subject[:fetch_command]} #{subject[:beans_url]}"
57
- end
58
- default_config :fetch_url do |subject|
59
- "http://gim.me/beans-for/#{subject.instance.name}"
60
- end
61
-
62
- required_config :need_it
63
- required_config :a_default
64
- required_config :no_nuts do |attr, value, _subject|
65
- raise UserError, "NO NUTS FOR #{attr}!" if value == "nuts"
66
- end
67
-
68
- expand_path_for :success_path
69
- expand_path_for :bunch_of_paths
70
- expand_path_for :relative_path, false
71
- expand_path_for :another_path
72
- expand_path_for :complex_path do |subject|
73
- subject[:something_else] == "is_set"
74
- end
75
-
76
- def initialize(config = {})
77
- init_config(config)
78
- end
79
- end
80
-
81
- class SubclassDefaults < StaticDefaults
82
- default_config :yea, "ya"
83
- default_config :fetch_command, "wget"
84
- default_config :fetch_url, "http://no.beans"
85
-
86
- required_config :a_default do |_attr, value, _subject|
87
- raise UserError, "Overriding a_default is fun" unless value == "please"
88
- end
89
-
90
- expand_path_for :another_path, false
91
- end
92
- end
93
- end
94
-
95
- describe Kitchen::Configurable do
96
- let(:config) { Hash.new }
97
- let(:platform) { stub }
98
- let(:instance) do
99
- stub(name: "coolbeans", to_str: "<instance>", platform: platform)
100
- end
101
-
102
- let(:subject) do
103
- Kitchen::Thing::Tiny.new(config).finalize_config!(instance)
104
- end
105
-
106
- describe "creation and setup" do
107
- it "#instance returns its instance" do
108
- subject.instance.must_equal instance
109
- end
110
-
111
- it "#finalize_config! raises ClientError if instance is nil" do
112
- proc { Kitchen::Thing::Tiny.new({}).finalize_config!(nil) }
113
- .must_raise(Kitchen::ClientError)
114
- end
115
-
116
- it "#finalize_config! returns self for chaining" do
117
- t = Kitchen::Thing::Tiny.new({})
118
- t.finalize_config!(instance).must_equal t
119
- end
120
- end
121
-
122
- describe "configuration" do
123
- describe "provided from the outside" do
124
- it "returns provided config" do
125
- config[:fruit] = %w{apples oranges}
126
- config[:cool_enough] = true
127
-
128
- subject[:fruit].must_equal %w{apples oranges}
129
- subject[:cool_enough].must_equal true
130
- end
131
- end
132
-
133
- describe "using static default_config statements" do
134
- let(:config) do
135
- { need_it: true, a_default: true }
136
- end
137
-
138
- let(:subject) do
139
- Kitchen::Thing::StaticDefaults.new(config).finalize_config!(instance)
140
- end
141
-
142
- it "uses defaults" do
143
- subject[:beans].must_equal "kidney"
144
- subject[:tunables]["flimflam"].must_equal "positate"
145
- subject[:edible].must_equal true
146
- end
147
-
148
- it "uses provided config over default_config" do
149
- config[:beans] = "pinto"
150
- config[:edible] = false
151
-
152
- subject[:beans].must_equal "pinto"
153
- subject[:edible].must_equal false
154
- end
155
-
156
- it "uses other config values to compute values" do
157
- subject[:beans_url].must_equal "http://gim.me/kidney"
158
- subject[:command].must_equal "curl http://gim.me/kidney"
159
- end
160
-
161
- it "computed value blocks have access to instance object" do
162
- subject[:fetch_url].must_equal "http://gim.me/beans-for/coolbeans"
163
- end
164
-
165
- it "uses provided config over default_config for computed values" do
166
- config[:command] = "echo listentome"
167
- config[:beans] = "pinto"
168
-
169
- subject[:command].must_equal "echo listentome"
170
- subject[:beans_url].must_equal "http://gim.me/pinto"
171
- end
172
- end
173
-
174
- describe "using inherited static default_config statements" do
175
- let(:config) do
176
- { need_it: true, a_default: "please" }
177
- end
178
-
179
- let(:subject) do
180
- Kitchen::Thing::SubclassDefaults.new(config).finalize_config!(instance)
181
- end
182
-
183
- it "contains defaults from superclass" do
184
- subject[:beans].must_equal "kidney"
185
- subject[:tunables]["flimflam"].must_equal "positate"
186
- subject[:edible].must_equal true
187
- subject[:yea].must_equal "ya"
188
- end
189
-
190
- it "uses provided config over default config" do
191
- config[:beans] = "pinto"
192
- config[:edible] = false
193
-
194
- subject[:beans].must_equal "pinto"
195
- subject[:edible].must_equal false
196
- subject[:yea].must_equal "ya"
197
- subject[:beans_url].must_equal "http://gim.me/pinto"
198
- end
199
-
200
- it "uses its own default_config over inherited default_config" do
201
- subject[:fetch_url].must_equal "http://no.beans"
202
- subject[:command].must_equal "wget http://gim.me/kidney"
203
- end
204
- end
205
-
206
- describe "using static required_config statements" do
207
- let(:config) do
208
- { a_default: true }
209
- end
210
-
211
- let(:subject) do
212
- Kitchen::Thing::StaticDefaults.new(config).finalize_config!(instance)
213
- end
214
-
215
- it "uses a value when provided" do
216
- config[:need_it] = "okay"
217
-
218
- subject[:need_it].must_equal "okay"
219
- end
220
-
221
- it "without a block, raises a UserError if attr is nil" do
222
- config[:need_it] = nil
223
-
224
- begin
225
- subject
226
- flunk "UserError must be raised"
227
- rescue Kitchen::UserError => e
228
- attr = "Kitchen::Thing::StaticDefaults<instance>#config[:need_it]"
229
- e.message.must_equal "#{attr} cannot be blank"
230
- end
231
- end
232
-
233
- it "without a block, raises a UserError if attr is an empty string" do
234
- config[:need_it] = ""
235
-
236
- begin
237
- subject
238
- flunk "UserError must be raised"
239
- rescue Kitchen::UserError => e
240
- attr = "Kitchen::Thing::StaticDefaults<instance>#config[:need_it]"
241
- e.message.must_equal "#{attr} cannot be blank"
242
- end
243
- end
244
-
245
- it "with a block, it is saved and invoked" do
246
- config[:need_it] = "okay"
247
- config[:no_nuts] = "nuts"
248
-
249
- begin
250
- subject
251
- flunk "UserError must be raised"
252
- rescue Kitchen::UserError => e
253
- e.message.must_equal "NO NUTS FOR no_nuts!"
254
- end
255
- end
256
- end
257
-
258
- describe "using inherited static require_config statements" do
259
- let(:subject) do
260
- Kitchen::Thing::SubclassDefaults.new(config).finalize_config!(instance)
261
- end
262
-
263
- it "contains required config from superclass" do
264
- config[:a_default] = nil
265
- config[:need_it] = nil
266
-
267
- begin
268
- subject
269
- flunk "UserError must be raised"
270
- rescue Kitchen::UserError => e
271
- attr = "Kitchen::Thing::StaticDefaults<instance>#config[:need_it]"
272
- e.message.must_equal "#{attr} cannot be blank"
273
- end
274
- end
275
-
276
- it "uses its own require_config over inherited require_config" do
277
- config[:need_it] = true
278
- config[:a_default] = nil
279
-
280
- begin
281
- subject
282
- flunk "UserError must be raised"
283
- rescue Kitchen::UserError => e
284
- e.message.must_equal "Overriding a_default is fun"
285
- end
286
- end
287
- end
288
-
289
- describe "using static expand_path_for statements" do
290
- let(:config) do
291
- { need_it: "a", a_default: "b", kitchen_root: "/tmp/yo/self" }
292
- end
293
-
294
- let(:subject) do
295
- Kitchen::Thing::StaticDefaults.new(config).finalize_config!(instance)
296
- end
297
-
298
- it "expands a default value" do
299
- subject[:success_path].must_equal os_safe_root_path("/tmp/yo/self/success")
300
- end
301
-
302
- it "uses provided config over default_config" do
303
- config[:success_path] = "mine"
304
-
305
- subject[:success_path].must_equal os_safe_root_path("/tmp/yo/self/mine")
306
- end
307
-
308
- it "leaves a full path expanded" do
309
- config[:success_path] = "/the/other/one"
310
-
311
- subject[:success_path].must_equal os_safe_root_path("/the/other/one")
312
- end
313
-
314
- it "expands all items if path is an array" do
315
- paths = %w{
316
- /tmp/yo/self/a /tmp/yo/self/b /tmp/yo/self/c
317
- }
318
- os_safe_paths = paths.collect { |path| os_safe_root_path(path) }
319
- subject[:bunch_of_paths].must_equal os_safe_paths
320
- end
321
-
322
- it "doesn't expand path with a falsy expand_path_for value" do
323
- config[:relative_path] = "./rel"
324
-
325
- subject[:relative_path].must_equal "./rel"
326
- end
327
-
328
- it "expands a path if a lambda returns truthy" do
329
- config[:something_else] = "is_set"
330
- config[:complex_path] = "./complex"
331
-
332
- subject[:complex_path].must_equal os_safe_root_path("/tmp/yo/self/complex")
333
- end
334
-
335
- it "leaves a nil config value as nil" do
336
- config[:success_path] = nil
337
-
338
- subject[:success_path].must_be_nil
339
- end
340
-
341
- it "leaves a false config value as false" do
342
- config[:success_path] = false
343
-
344
- subject[:success_path].must_equal false
345
- end
346
- end
347
-
348
- describe "using inherited static expand_path_for statements" do
349
- let(:config) do
350
- { need_it: "a", a_default: "please", kitchen_root: "/rooty" }
351
- end
352
-
353
- let(:subject) do
354
- Kitchen::Thing::SubclassDefaults.new(config).finalize_config!(instance)
355
- end
356
-
357
- it "contains expand_path_for from superclass" do
358
- subject[:success_path].must_equal os_safe_root_path("/rooty/success")
359
- end
360
-
361
- it "uses its own expand_path_for over inherited expand_path_for" do
362
- config[:another_path] = "./pp"
363
-
364
- subject[:another_path].must_equal "./pp"
365
- end
366
- end
367
-
368
- it "#config_keys returns an array of config key names" do
369
- subject = Kitchen::Thing::Tiny.new(ice_cream: "dragon")
370
-
371
- subject.config_keys.sort.must_equal [:ice_cream]
372
- end
373
- end
374
-
375
- it "#name returns the name of the plugin" do
376
- subject.name.must_equal "Tiny"
377
- end
378
-
379
- describe "#diagnose" do
380
- it "returns an empty hash for no config" do
381
- subject.diagnose.must_equal Hash.new
382
- end
383
-
384
- it "returns a hash of config" do
385
- config[:alpha] = "beta"
386
- subject.diagnose.must_equal(alpha: "beta")
387
- end
388
-
389
- it "returns a hash with sorted keys" do
390
- config[:zebra] = true
391
- config[:elephant] = true
392
-
393
- subject.diagnose.keys.must_equal [:elephant, :zebra]
394
- end
395
- end
396
-
397
- describe "#diagnose_plugin" do
398
- it "returns a plugin hash for a plugin without version" do
399
- subject.diagnose_plugin.must_equal(
400
- name: "Tiny", class: "Kitchen::Thing::Tiny",
401
- version: nil, api_version: nil
402
- )
403
- end
404
-
405
- it "returns a plugin hash for a plugin with version" do
406
- subject = Kitchen::Thing::Versioned.new(config).finalize_config!(instance)
407
- subject.diagnose_plugin.must_equal(
408
- name: "Versioned", class: "Kitchen::Thing::Versioned",
409
- version: "1.8.17", api_version: nil
410
- )
411
- end
412
- end
413
-
414
- describe "#calculate_path" do
415
- let(:config) do
416
- { test_base_path: "/the/basest" }
417
- end
418
-
419
- let(:suite) do
420
- stub(name: "ultimate")
421
- end
422
-
423
- let(:instance) do
424
- stub(name: "coolbeans", to_str: "<instance>", suite: suite)
425
- end
426
-
427
- let(:subject) do
428
- Kitchen::Thing::Tiny.new(config).finalize_config!(instance)
429
- end
430
-
431
- before do
432
- FakeFS.activate!
433
- end
434
-
435
- after do
436
- FakeFS.deactivate!
437
- FakeFS::FileSystem.clear
438
- end
439
-
440
- describe "for directories" do
441
- before do
442
- FileUtils.mkdir_p(File.join(Dir.pwd, "winner"))
443
- FileUtils.mkdir_p("/the/basest/winner")
444
- FileUtils.mkdir_p("/the/basest/ultimate/winner")
445
- end
446
-
447
- it "prefers a path containing base path and suite name if it exists" do
448
- subject.calculate_path("winner")
449
- .must_equal "/the/basest/ultimate/winner"
450
- end
451
-
452
- it "prefers a path containing base path if it exists" do
453
- FileUtils.rm_rf("/the/basest/ultimate/winner")
454
-
455
- subject.calculate_path("winner").must_equal "/the/basest/winner"
456
- end
457
-
458
- it "prefers a path in the current working directory if it exists" do
459
- FileUtils.rm_rf("/the/basest/ultimate/winner")
460
- FileUtils.rm_rf("/the/basest/winner")
461
- pwd_dir = File.join(Dir.pwd, "winner")
462
-
463
- subject.calculate_path("winner").must_equal pwd_dir
464
- end
465
-
466
- it "raises a UserError if test_base_path key is not set" do
467
- config.delete(:test_base_path)
468
-
469
- proc { subject.calculate_path("winner") }.must_raise Kitchen::UserError
470
- end
471
-
472
- it "uses a custom base path" do
473
- FileUtils.mkdir_p("/custom/ultimate/winner")
474
-
475
- subject.calculate_path("winner", base_path: "/custom")
476
- .must_equal "/custom/ultimate/winner"
477
- end
478
- end
479
-
480
- describe "for files" do
481
- before do
482
- FileUtils.mkdir_p(Dir.pwd)
483
- FileUtils.touch(File.join(Dir.pwd, "winner"))
484
- FileUtils.mkdir_p("/the/basest")
485
- FileUtils.touch(File.join("/the/basest", "winner"))
486
- FileUtils.mkdir_p("/the/basest/ultimate")
487
- FileUtils.touch(File.join("/the/basest/ultimate", "winner"))
488
- end
489
-
490
- it "prefers a path containing base path and suite name if it exists" do
491
- subject.calculate_path("winner", type: :file)
492
- .must_equal "/the/basest/ultimate/winner"
493
- end
494
-
495
- it "prefers a path containing base path if it exists" do
496
- FileUtils.rm_rf("/the/basest/ultimate/winner")
497
-
498
- subject.calculate_path("winner", type: :file)
499
- .must_equal "/the/basest/winner"
500
- end
501
-
502
- it "prefers a path in the current working directory if it exists" do
503
- FileUtils.rm_rf("/the/basest/ultimate/winner")
504
- FileUtils.rm_rf("/the/basest/winner")
505
- pwd_dir = File.join(Dir.pwd, "winner")
506
-
507
- subject.calculate_path("winner", type: :file).must_equal pwd_dir
508
- end
509
-
510
- it "raises a UserError if test_base_path key is not set" do
511
- config.delete(:test_base_path)
512
-
513
- proc { subject.calculate_path("winner") }.must_raise Kitchen::UserError
514
- end
515
-
516
- it "uses a custom base path" do
517
- FileUtils.mkdir_p("/custom/ultimate")
518
- FileUtils.touch(File.join("/custom/ultimate", "winner"))
519
-
520
- subject.calculate_path("winner", type: :file, base_path: "/custom")
521
- .must_equal "/custom/ultimate/winner"
522
- end
523
- end
524
- end
525
-
526
- describe "#remote_path_join" do
527
- it "returns unix style path separators for unix os_type" do
528
- platform.stubs(:os_type).returns("unix")
529
-
530
- subject.remote_path_join("a", "b", "c").must_equal "a/b/c"
531
- end
532
-
533
- it "returns windows style path separators for windows os_type" do
534
- platform.stubs(:os_type).returns("windows")
535
-
536
- subject.remote_path_join("a", "b", "c").must_equal 'a\\b\\c'
537
- end
538
-
539
- it "accepts combinations of strings and arrays" do
540
- platform.stubs(:os_type).returns("unix")
541
-
542
- subject.remote_path_join(%w{a b}, "c", %w{d e}).must_equal "a/b/c/d/e"
543
- end
544
-
545
- it "accepts a single array" do
546
- platform.stubs(:os_type).returns("windows")
547
-
548
- subject.remote_path_join(%w{a b}).must_equal 'a\\b'
549
- end
550
-
551
- it "converts all windows path separators to unix for unix os_type" do
552
- platform.stubs(:os_type).returns("unix")
553
-
554
- subject.remote_path_join('\\a\\b', "c/d").must_equal "/a/b/c/d"
555
- end
556
-
557
- it "converts all unix path separators to windows for windows os_type" do
558
- platform.stubs(:os_type).returns("windows")
559
-
560
- subject.remote_path_join("/a/b", 'c\\d').must_equal '\\a\\b\\c\\d'
561
- end
562
- end
563
-
564
- describe "#windows_os?" do
565
- it "for windows type platform returns true" do
566
- platform.stubs(:os_type).returns("windows")
567
-
568
- subject.windows_os?.must_equal true
569
- end
570
-
571
- it "for unix type platform returns false" do
572
- platform.stubs(:os_type).returns("unix")
573
-
574
- subject.windows_os?.must_equal false
575
- end
576
-
577
- it "for newfangled type platform return false" do
578
- platform.stubs(:os_type).returns("internet_cat")
579
-
580
- subject.windows_os?.must_equal false
581
- end
582
-
583
- it "for unset type platform returns false" do
584
- platform.stubs(:os_type).returns(nil)
585
-
586
- subject.windows_os?.must_equal false
587
- end
588
- end
589
-
590
- describe "#unix_os?" do
591
- it "for windows type platform returns false" do
592
- platform.stubs(:os_type).returns("windows")
593
-
594
- subject.unix_os?.must_equal false
595
- end
596
-
597
- it "for unix type platform returns true" do
598
- platform.stubs(:os_type).returns("unix")
599
-
600
- subject.unix_os?.must_equal true
601
- end
602
-
603
- it "for newfangled type platform return false" do
604
- platform.stubs(:os_type).returns("internet_cat")
605
-
606
- subject.unix_os?.must_equal false
607
- end
608
-
609
- it "for unset type platform returns true" do
610
- platform.stubs(:os_type).returns(nil)
611
-
612
- subject.unix_os?.must_equal true
613
- end
614
- end
615
-
616
- describe "#powershell_shell?" do
617
- it "for powershell type shell returns true" do
618
- platform.stubs(:shell_type).returns("powershell")
619
-
620
- subject.powershell_shell?.must_equal true
621
- end
622
-
623
- it "for bourne type shell returns false" do
624
- platform.stubs(:shell_type).returns("bourne")
625
-
626
- subject.powershell_shell?.must_equal false
627
- end
628
-
629
- it "for newfangled type shell return false" do
630
- platform.stubs(:shell_type).returns("internet_cat")
631
-
632
- subject.powershell_shell?.must_equal false
633
- end
634
-
635
- it "for unset type shell returns false" do
636
- platform.stubs(:shell_type).returns(nil)
637
-
638
- subject.powershell_shell?.must_equal false
639
- end
640
- end
641
-
642
- describe "#bourne_shell?" do
643
- it "for powershell type shell returns false" do
644
- platform.stubs(:shell_type).returns("powershell")
645
-
646
- subject.bourne_shell?.must_equal false
647
- end
648
-
649
- it "for bourne type shell returns true" do
650
- platform.stubs(:shell_type).returns("bourne")
651
-
652
- subject.bourne_shell?.must_equal true
653
- end
654
-
655
- it "for newfangled type shell return false" do
656
- platform.stubs(:shell_type).returns("internet_cat")
657
-
658
- subject.bourne_shell?.must_equal false
659
- end
660
-
661
- it "for unset type shell returns true" do
662
- platform.stubs(:shell_type).returns(nil)
663
-
664
- subject.bourne_shell?.must_equal true
665
- end
666
- end
667
-
668
- describe "#shell_env_var" do
669
- it "for powershell type shells returns a powershell environment variable" do
670
- platform.stubs(:shell_type).returns("powershell")
671
-
672
- subject.send(:shell_env_var, "foo", "bar")
673
- .must_equal %{$env:foo = "bar"}
674
- end
675
-
676
- it "for bourne type shells returns a bourne environment variable" do
677
- platform.stubs(:shell_type).returns("bourne")
678
-
679
- subject.send(:shell_env_var, "foo", "bar")
680
- .must_equal %{foo="bar"; export foo}
681
- end
682
- end
683
-
684
- describe "#shell_var" do
685
- it "for powershell type shells returns a powershell variable" do
686
- platform.stubs(:shell_type).returns("powershell")
687
-
688
- subject.send(:shell_var, "foo", "bar").must_equal %{$foo = "bar"}
689
- end
690
-
691
- it "for bourne type shells returns a bourne variable" do
692
- platform.stubs(:shell_type).returns("bourne")
693
-
694
- subject.send(:shell_var, "foo", "bar").must_equal %{foo="bar"}
695
- end
696
- end
697
-
698
- describe "#wrap_shell_code" do
699
- let(:cmd) { subject.send(:wrap_shell_code, "mkdir foo") }
700
-
701
- before do
702
- @original_env = ENV.to_hash
703
- ENV.replace("http_proxy" => nil, "HTTP_PROXY" => nil,
704
- "https_proxy" => nil, "HTTPS_PROXY" => nil,
705
- "ftp_proxy" => nil, "FTP_PROXY" => nil,
706
- "no_proxy" => nil, "NO_PROXY" => nil,
707
- "CI" => nil)
708
- end
709
-
710
- after do
711
- ENV.clear
712
- ENV.replace(@original_env)
713
- end
714
-
715
- describe "for bourne shells" do
716
- before { platform.stubs(:shell_type).returns("bourne") }
717
-
718
- it "uses bourne shell (sh)" do
719
- cmd.must_equal(outdent!(<<-CODE.chomp))
720
- sh -c '
721
- TEST_KITCHEN="1"; export TEST_KITCHEN
722
- mkdir foo
723
- '
724
- CODE
725
- end
726
-
727
- it "exports http_proxy & HTTP_PROXY when :http_proxy is set" do
728
- config[:http_proxy] = "http://proxy"
729
-
730
- cmd.must_equal(outdent!(<<-CODE.chomp))
731
- sh -c '
732
- http_proxy="http://proxy"; export http_proxy
733
- HTTP_PROXY="http://proxy"; export HTTP_PROXY
734
- TEST_KITCHEN="1"; export TEST_KITCHEN
735
- mkdir foo
736
- '
737
- CODE
738
- end
739
-
740
- it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
741
- config[:https_proxy] = "https://proxy"
742
-
743
- cmd.must_equal(outdent!(<<-CODE.chomp))
744
- sh -c '
745
- https_proxy="https://proxy"; export https_proxy
746
- HTTPS_PROXY="https://proxy"; export HTTPS_PROXY
747
- TEST_KITCHEN="1"; export TEST_KITCHEN
748
- mkdir foo
749
- '
750
- CODE
751
- end
752
-
753
- it "exports ftp_proxy & FTP_PROXY when :ftp_proxy is set" do
754
- config[:ftp_proxy] = "ftp://proxy"
755
-
756
- cmd.must_equal(outdent!(<<-CODE.chomp))
757
- sh -c '
758
- ftp_proxy="ftp://proxy"; export ftp_proxy
759
- FTP_PROXY="ftp://proxy"; export FTP_PROXY
760
- TEST_KITCHEN="1"; export TEST_KITCHEN
761
- mkdir foo
762
- '
763
- CODE
764
- end
765
-
766
- it "exports all http proxy variables when all are set" do
767
- config[:http_proxy] = "http://proxy"
768
- config[:https_proxy] = "https://proxy"
769
- config[:ftp_proxy] = "ftp://proxy"
770
- config[:no_proxy] = "http://no"
771
-
772
- cmd.must_equal(outdent!(<<-CODE.chomp))
773
- sh -c '
774
- http_proxy="http://proxy"; export http_proxy
775
- HTTP_PROXY="http://proxy"; export HTTP_PROXY
776
- https_proxy="https://proxy"; export https_proxy
777
- HTTPS_PROXY="https://proxy"; export HTTPS_PROXY
778
- ftp_proxy="ftp://proxy"; export ftp_proxy
779
- FTP_PROXY="ftp://proxy"; export FTP_PROXY
780
- no_proxy="http://no"; export no_proxy
781
- NO_PROXY="http://no"; export NO_PROXY
782
- TEST_KITCHEN="1"; export TEST_KITCHEN
783
- mkdir foo
784
- '
785
- CODE
786
- end
787
-
788
- it "exports http_proxy & HTTP_PROXY from workstation when :http_proxy isn't set" do
789
- ENV["http_proxy"] = "http://proxy"
790
- ENV["HTTP_PROXY"] = "http://proxy"
791
-
792
- cmd.must_equal(outdent!(<<-CODE.chomp))
793
- sh -c '
794
- http_proxy="http://proxy"; export http_proxy
795
- HTTP_PROXY="http://proxy"; export HTTP_PROXY
796
- TEST_KITCHEN="1"; export TEST_KITCHEN
797
- mkdir foo
798
- '
799
- CODE
800
- end
801
-
802
- it "exports https_proxy & HTTPS_PROXY from workstation when :https_proxy isn't set" do
803
- ENV["https_proxy"] = "https://proxy"
804
- ENV["HTTPS_PROXY"] = "https://proxy"
805
-
806
- cmd.must_equal(outdent!(<<-CODE.chomp))
807
- sh -c '
808
- https_proxy="https://proxy"; export https_proxy
809
- HTTPS_PROXY="https://proxy"; export HTTPS_PROXY
810
- TEST_KITCHEN="1"; export TEST_KITCHEN
811
- mkdir foo
812
- '
813
- CODE
814
- end
815
-
816
- it "does not export http_proxy or HTTP_PROXY when :http_proxy is empty" do
817
- ENV["http_proxy"] = "http://proxy"
818
- ENV["HTTP_PROXY"] = "http://proxy"
819
- config[:http_proxy] = ""
820
-
821
- cmd.must_equal(outdent!(<<-CODE.chomp))
822
- sh -c '
823
- TEST_KITCHEN="1"; export TEST_KITCHEN
824
- mkdir foo
825
- '
826
- CODE
827
- end
828
-
829
- it "does not export https_proxy or HTTPS_PROXY when :https_proxy is empty" do
830
- ENV["https_proxy"] = "https://proxy"
831
- ENV["HTTPS_PROXY"] = "https://proxy"
832
- config[:https_proxy] = ""
833
-
834
- cmd.must_equal(outdent!(<<-CODE.chomp))
835
- sh -c '
836
- TEST_KITCHEN="1"; export TEST_KITCHEN
837
- mkdir foo
838
- '
839
- CODE
840
- end
841
-
842
- it "exports ftp_proxy & FTP_PROXY from workstation when :ftp_proxy isn't set" do
843
- ENV["ftp_proxy"] = "ftp://proxy"
844
- ENV["FTP_PROXY"] = "ftp://proxy"
845
-
846
- cmd.must_equal(outdent!(<<-CODE.chomp))
847
- sh -c '
848
- ftp_proxy="ftp://proxy"; export ftp_proxy
849
- FTP_PROXY="ftp://proxy"; export FTP_PROXY
850
- TEST_KITCHEN="1"; export TEST_KITCHEN
851
- mkdir foo
852
- '
853
- CODE
854
- end
855
-
856
- it "does not export ftp_proxy or FTP_PROXY when :ftp_proxy is empty" do
857
- config[:ftp_proxy] = ""
858
-
859
- cmd.must_equal(outdent!(<<-CODE.chomp))
860
- sh -c '
861
- TEST_KITCHEN="1"; export TEST_KITCHEN
862
- mkdir foo
863
- '
864
- CODE
865
- end
866
-
867
- it "exports no_proxy & NO_PROXY from workstation when http_proxy is set from workstation" do
868
- ENV["http_proxy"] = "http://proxy"
869
- ENV["HTTP_PROXY"] = "http://proxy"
870
- ENV["no_proxy"] = "http://no"
871
- ENV["NO_PROXY"] = "http://no"
872
-
873
- cmd.must_equal(outdent!(<<-CODE.chomp))
874
- sh -c '
875
- http_proxy="http://proxy"; export http_proxy
876
- HTTP_PROXY="http://proxy"; export HTTP_PROXY
877
- no_proxy="http://no"; export no_proxy
878
- NO_PROXY="http://no"; export NO_PROXY
879
- TEST_KITCHEN="1"; export TEST_KITCHEN
880
- mkdir foo
881
- '
882
- CODE
883
- end
884
-
885
- it "exports no_proxy & NO_PROXY from workstation when https_proxy is set from workstation" do
886
- ENV["https_proxy"] = "https://proxy"
887
- ENV["HTTPS_PROXY"] = "https://proxy"
888
- ENV["no_proxy"] = "http://no"
889
- ENV["NO_PROXY"] = "http://no"
890
-
891
- cmd.must_equal(outdent!(<<-CODE.chomp))
892
- sh -c '
893
- https_proxy="https://proxy"; export https_proxy
894
- HTTPS_PROXY="https://proxy"; export HTTPS_PROXY
895
- no_proxy="http://no"; export no_proxy
896
- NO_PROXY="http://no"; export NO_PROXY
897
- TEST_KITCHEN="1"; export TEST_KITCHEN
898
- mkdir foo
899
- '
900
- CODE
901
- end
902
-
903
- it "exports no_proxy & NO_PROXY from workstation when ftp_proxy is set from workstation" do
904
- ENV["ftp_proxy"] = "ftp://proxy"
905
- ENV["FTP_PROXY"] = "ftp://proxy"
906
- ENV["no_proxy"] = "http://no"
907
- ENV["NO_PROXY"] = "http://no"
908
-
909
- cmd.must_equal(outdent!(<<-CODE.chomp))
910
- sh -c '
911
- ftp_proxy="ftp://proxy"; export ftp_proxy
912
- FTP_PROXY="ftp://proxy"; export FTP_PROXY
913
- no_proxy="http://no"; export no_proxy
914
- NO_PROXY="http://no"; export NO_PROXY
915
- TEST_KITCHEN="1"; export TEST_KITCHEN
916
- mkdir foo
917
- '
918
- CODE
919
- end
920
-
921
- it "exports CI when CI is set" do
922
- ENV["CI"] = "1"
923
-
924
- cmd.must_equal(outdent!(<<-CODE.chomp))
925
- sh -c '
926
- TEST_KITCHEN="1"; export TEST_KITCHEN
927
- CI="1"; export CI
928
- mkdir foo
929
- '
930
- CODE
931
- end
932
- end
933
-
934
- describe "for powershell shells" do
935
- before { platform.stubs(:shell_type).returns("powershell") }
936
-
937
- it "uses powershell shell" do
938
- cmd.must_equal("$env:TEST_KITCHEN = \"1\"\nmkdir foo")
939
- end
940
-
941
- it "exports http_proxy & HTTP_PROXY when :http_proxy is set" do
942
- config[:http_proxy] = "http://proxy"
943
-
944
- cmd.must_equal(outdent!(<<-CODE.chomp))
945
- $env:http_proxy = "http://proxy"
946
- $env:HTTP_PROXY = "http://proxy"
947
- $env:TEST_KITCHEN = "1"
948
- mkdir foo
949
- CODE
950
- end
951
-
952
- it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
953
- config[:https_proxy] = "https://proxy"
954
-
955
- cmd.must_equal(outdent!(<<-CODE.chomp))
956
- $env:https_proxy = "https://proxy"
957
- $env:HTTPS_PROXY = "https://proxy"
958
- $env:TEST_KITCHEN = "1"
959
- mkdir foo
960
- CODE
961
- end
962
-
963
- it "exports ftp_proxy & FTP_PROXY when :ftp_proxy is set" do
964
- config[:ftp_proxy] = "ftp://proxy"
965
-
966
- cmd.must_equal(outdent!(<<-CODE.chomp))
967
- $env:ftp_proxy = "ftp://proxy"
968
- $env:FTP_PROXY = "ftp://proxy"
969
- $env:TEST_KITCHEN = "1"
970
- mkdir foo
971
- CODE
972
- end
973
-
974
- it "exports all http proxy variables when all are set" do
975
- config[:http_proxy] = "http://proxy"
976
- config[:https_proxy] = "https://proxy"
977
- config[:ftp_proxy] = "ftp://proxy"
978
-
979
- cmd.must_equal(outdent!(<<-CODE.chomp))
980
- $env:http_proxy = "http://proxy"
981
- $env:HTTP_PROXY = "http://proxy"
982
- $env:https_proxy = "https://proxy"
983
- $env:HTTPS_PROXY = "https://proxy"
984
- $env:ftp_proxy = "ftp://proxy"
985
- $env:FTP_PROXY = "ftp://proxy"
986
- $env:TEST_KITCHEN = "1"
987
- mkdir foo
988
- CODE
989
- end
990
-
991
- it "exports http_proxy & HTTP_PROXY from workstation when :http_proxy isn't set" do
992
- ENV["http_proxy"] = "http://proxy"
993
- ENV["HTTP_PROXY"] = "http://proxy"
994
-
995
- cmd.must_equal(outdent!(<<-CODE.chomp))
996
- $env:http_proxy = "http://proxy"
997
- $env:HTTP_PROXY = "http://proxy"
998
- $env:TEST_KITCHEN = "1"
999
- mkdir foo
1000
- CODE
1001
- end
1002
-
1003
- it "exports https_proxy & HTTPS_PROXY from workstation when :https_proxy isn't set" do
1004
- ENV["https_proxy"] = "https://proxy"
1005
- ENV["HTTPS_PROXY"] = "https://proxy"
1006
-
1007
- cmd.must_equal(outdent!(<<-CODE.chomp))
1008
- $env:https_proxy = "https://proxy"
1009
- $env:HTTPS_PROXY = "https://proxy"
1010
- $env:TEST_KITCHEN = "1"
1011
- mkdir foo
1012
- CODE
1013
- end
1014
-
1015
- it "exports ftp_proxy & FTP_PROXY from workstation when :ftp_proxy isn't set" do
1016
- ENV["ftp_proxy"] = "ftp://proxy"
1017
- ENV["FTP_PROXY"] = "ftp://proxy"
1018
-
1019
- cmd.must_equal(outdent!(<<-CODE.chomp))
1020
- $env:ftp_proxy = "ftp://proxy"
1021
- $env:FTP_PROXY = "ftp://proxy"
1022
- $env:TEST_KITCHEN = "1"
1023
- mkdir foo
1024
- CODE
1025
- end
1026
-
1027
- it "exports no_proxy & NO_PROXY from workstation when http_proxy is set from workstation" do
1028
- ENV["http_proxy"] = "http://proxy"
1029
- ENV["HTTP_PROXY"] = "http://proxy"
1030
- ENV["no_proxy"] = "http://no"
1031
- ENV["NO_PROXY"] = "http://no"
1032
-
1033
- cmd.must_equal(outdent!(<<-CODE.chomp))
1034
- $env:http_proxy = "http://proxy"
1035
- $env:HTTP_PROXY = "http://proxy"
1036
- $env:no_proxy = "http://no"
1037
- $env:NO_PROXY = "http://no"
1038
- $env:TEST_KITCHEN = "1"
1039
- mkdir foo
1040
- CODE
1041
- end
1042
-
1043
- it "exports no_proxy & NO_PROXY from workstation when https_proxy is set from workstation" do
1044
- ENV["https_proxy"] = "https://proxy"
1045
- ENV["HTTPS_PROXY"] = "https://proxy"
1046
- ENV["no_proxy"] = "http://no"
1047
- ENV["NO_PROXY"] = "http://no"
1048
-
1049
- cmd.must_equal(outdent!(<<-CODE.chomp))
1050
- $env:https_proxy = "https://proxy"
1051
- $env:HTTPS_PROXY = "https://proxy"
1052
- $env:no_proxy = "http://no"
1053
- $env:NO_PROXY = "http://no"
1054
- $env:TEST_KITCHEN = "1"
1055
- mkdir foo
1056
- CODE
1057
- end
1058
-
1059
- it "exports no_proxy & NO_PROXY from workstation when ftp_proxy is set from workstation" do
1060
- ENV["ftp_proxy"] = "ftp://proxy"
1061
- ENV["FTP_PROXY"] = "ftp://proxy"
1062
- ENV["no_proxy"] = "http://no"
1063
- ENV["NO_PROXY"] = "http://no"
1064
-
1065
- cmd.must_equal(outdent!(<<-CODE.chomp))
1066
- $env:ftp_proxy = "ftp://proxy"
1067
- $env:FTP_PROXY = "ftp://proxy"
1068
- $env:no_proxy = "http://no"
1069
- $env:NO_PROXY = "http://no"
1070
- $env:TEST_KITCHEN = "1"
1071
- mkdir foo
1072
- CODE
1073
- end
1074
-
1075
- it "exports CI when CI is set" do
1076
- ENV["CI"] = "1"
1077
-
1078
- cmd.must_equal(outdent!(<<-CODE.chomp))
1079
- $env:TEST_KITCHEN = "1"
1080
- $env:CI = "1"
1081
- mkdir foo
1082
- CODE
1083
- end
1084
- end
1085
- end
1086
-
1087
- it "has a default verify dependencies method" do
1088
- subject.verify_dependencies.must_be_nil
1089
- end
1090
-
1091
- describe "#logger" do
1092
- before { @klog = Kitchen.logger }
1093
- after { Kitchen.logger = @klog }
1094
-
1095
- it "returns the instance's logger" do
1096
- logger = stub("logger")
1097
- instance = stub(logger: logger)
1098
- subject = Kitchen::Thing::Tiny.new(config.merge(instance: instance))
1099
- subject.send(:logger).must_equal logger
1100
- end
1101
-
1102
- it "returns the default logger if instance's logger is not set" do
1103
- subject = Kitchen::Thing::Tiny.new(config)
1104
- Kitchen.logger = "yep"
1105
-
1106
- subject.send(:logger).must_equal Kitchen.logger
1107
- end
1108
- end
1109
-
1110
- def outdent!(*args)
1111
- Kitchen::Util.outdent!(*args)
1112
- end
1113
- end