puppet 4.7.1-universal-darwin → 4.8.0-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (276) hide show
  1. data/Gemfile +0 -3
  2. data/MAINTAINERS +76 -0
  3. data/README.md +0 -6
  4. data/Rakefile +2 -2
  5. data/lib/puppet/agent.rb +3 -3
  6. data/lib/puppet/application/apply.rb +1 -1
  7. data/lib/puppet/configurer.rb +2 -2
  8. data/lib/puppet/data_providers.rb +1 -0
  9. data/lib/puppet/data_providers/data_adapter.rb +1 -0
  10. data/lib/puppet/data_providers/data_function_support.rb +1 -0
  11. data/lib/puppet/data_providers/function_env_data_provider.rb +1 -0
  12. data/lib/puppet/data_providers/function_module_data_provider.rb +1 -0
  13. data/lib/puppet/data_providers/hiera_config.rb +1 -0
  14. data/lib/puppet/data_providers/hiera_env_data_provider.rb +1 -0
  15. data/lib/puppet/data_providers/hiera_interpolate.rb +1 -0
  16. data/lib/puppet/data_providers/hiera_module_data_provider.rb +1 -0
  17. data/lib/puppet/data_providers/hiera_support.rb +1 -2
  18. data/lib/puppet/data_providers/json_data_provider_factory.rb +2 -0
  19. data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -0
  20. data/lib/puppet/defaults.rb +20 -1
  21. data/lib/puppet/environments.rb +5 -2
  22. data/lib/puppet/face/catalog.rb +1 -1
  23. data/lib/puppet/face/epp.rb +57 -11
  24. data/lib/puppet/face/module/install.rb +6 -6
  25. data/lib/puppet/functions.rb +23 -24
  26. data/lib/puppet/functions/alert.rb +14 -0
  27. data/lib/puppet/functions/binary_file.rb +25 -0
  28. data/lib/puppet/functions/break.rb +22 -0
  29. data/lib/puppet/functions/contain.rb +33 -0
  30. data/lib/puppet/functions/crit.rb +14 -0
  31. data/lib/puppet/functions/debug.rb +14 -0
  32. data/lib/puppet/functions/emerg.rb +14 -0
  33. data/lib/puppet/functions/epp.rb +1 -1
  34. data/lib/puppet/functions/err.rb +14 -0
  35. data/lib/puppet/functions/find_file.rb +31 -0
  36. data/lib/puppet/functions/include.rb +21 -0
  37. data/lib/puppet/functions/info.rb +14 -0
  38. data/lib/puppet/functions/new.rb +1 -1
  39. data/lib/puppet/functions/next.rb +23 -0
  40. data/lib/puppet/functions/notice.rb +14 -0
  41. data/lib/puppet/functions/regsubst.rb +12 -16
  42. data/lib/puppet/functions/require.rb +37 -0
  43. data/lib/puppet/functions/return.rb +22 -0
  44. data/lib/puppet/functions/strftime.rb +35 -0
  45. data/lib/puppet/functions/warning.rb +14 -0
  46. data/lib/puppet/generate/models/type/type.rb +4 -0
  47. data/lib/puppet/generate/templates/type/pcore.erb +2 -1
  48. data/lib/puppet/indirector/face.rb +6 -1
  49. data/lib/puppet/network/http/error.rb +2 -2
  50. data/lib/puppet/network/http/handler.rb +2 -2
  51. data/lib/puppet/node/environment.rb +11 -0
  52. data/lib/puppet/parser/ast.rb +5 -0
  53. data/lib/puppet/parser/ast/pops_bridge.rb +17 -4
  54. data/lib/puppet/parser/compiler.rb +29 -1
  55. data/lib/puppet/parser/functions.rb +6 -0
  56. data/lib/puppet/parser/functions/assert_type.rb +1 -1
  57. data/lib/puppet/parser/functions/binary_file.rb +24 -0
  58. data/lib/puppet/parser/functions/break.rb +39 -0
  59. data/lib/puppet/parser/functions/contain.rb +7 -15
  60. data/lib/puppet/parser/functions/defined.rb +2 -2
  61. data/lib/puppet/parser/functions/dig.rb +1 -1
  62. data/lib/puppet/parser/functions/each.rb +1 -1
  63. data/lib/puppet/parser/functions/epp.rb +2 -2
  64. data/lib/puppet/parser/functions/filter.rb +1 -1
  65. data/lib/puppet/parser/functions/find_file.rb +28 -0
  66. data/lib/puppet/parser/functions/hiera.rb +4 -4
  67. data/lib/puppet/parser/functions/hiera_array.rb +1 -1
  68. data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
  69. data/lib/puppet/parser/functions/hiera_include.rb +1 -1
  70. data/lib/puppet/parser/functions/include.rb +4 -8
  71. data/lib/puppet/parser/functions/inline_epp.rb +1 -1
  72. data/lib/puppet/parser/functions/lest.rb +1 -1
  73. data/lib/puppet/parser/functions/lookup.rb +4 -2
  74. data/lib/puppet/parser/functions/map.rb +1 -1
  75. data/lib/puppet/parser/functions/match.rb +1 -1
  76. data/lib/puppet/parser/functions/new.rb +414 -18
  77. data/lib/puppet/parser/functions/next.rb +38 -0
  78. data/lib/puppet/parser/functions/reduce.rb +1 -1
  79. data/lib/puppet/parser/functions/regsubst.rb +4 -2
  80. data/lib/puppet/parser/functions/require.rb +4 -27
  81. data/lib/puppet/parser/functions/return.rb +71 -0
  82. data/lib/puppet/parser/functions/reverse_each.rb +1 -1
  83. data/lib/puppet/parser/functions/scanf.rb +13 -8
  84. data/lib/puppet/parser/functions/slice.rb +1 -1
  85. data/lib/puppet/parser/functions/split.rb +1 -1
  86. data/lib/puppet/parser/functions/step.rb +1 -1
  87. data/lib/puppet/parser/functions/strftime.rb +185 -0
  88. data/lib/puppet/parser/functions/then.rb +1 -1
  89. data/lib/puppet/parser/functions/type.rb +1 -1
  90. data/lib/puppet/parser/functions/with.rb +3 -3
  91. data/lib/puppet/parser/resource.rb +8 -5
  92. data/lib/puppet/parser/scope.rb +1 -1
  93. data/lib/puppet/plugins/configuration.rb +8 -0
  94. data/lib/puppet/plugins/data_providers.rb +1 -0
  95. data/lib/puppet/plugins/data_providers/data_provider.rb +7 -28
  96. data/lib/puppet/plugins/data_providers/registry.rb +1 -0
  97. data/lib/puppet/pops.rb +4 -0
  98. data/lib/puppet/pops/evaluator/access_operator.rb +36 -5
  99. data/lib/puppet/pops/evaluator/closure.rb +81 -12
  100. data/lib/puppet/pops/evaluator/compare_operator.rb +24 -1
  101. data/lib/puppet/pops/evaluator/evaluator_impl.rb +29 -5
  102. data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +1 -1
  103. data/lib/puppet/pops/evaluator/runtime3_converter.rb +53 -62
  104. data/lib/puppet/pops/evaluator/runtime3_support.rb +15 -6
  105. data/lib/puppet/pops/functions/dispatch.rb +9 -2
  106. data/lib/puppet/pops/functions/dispatcher.rb +3 -1
  107. data/lib/puppet/pops/functions/function.rb +19 -2
  108. data/lib/puppet/pops/issues.rb +9 -0
  109. data/lib/puppet/pops/label_provider.rb +2 -2
  110. data/lib/puppet/pops/loader/loader.rb +17 -0
  111. data/lib/puppet/pops/loader/static_loader.rb +0 -41
  112. data/lib/puppet/pops/lookup.rb +12 -0
  113. data/lib/puppet/pops/lookup/context.rb +86 -0
  114. data/lib/puppet/pops/lookup/explainer.rb +46 -6
  115. data/lib/puppet/pops/lookup/invocation.rb +19 -0
  116. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  117. data/lib/puppet/pops/model/factory.rb +20 -8
  118. data/lib/puppet/pops/model/model_label_provider.rb +3 -0
  119. data/lib/puppet/pops/model/model_meta.rb +2 -0
  120. data/lib/puppet/pops/model/model_tree_dumper.rb +14 -0
  121. data/lib/puppet/pops/parser/egrammar.ra +11 -6
  122. data/lib/puppet/pops/parser/eparser.rb +1112 -1086
  123. data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
  124. data/lib/puppet/pops/pcore.rb +1 -0
  125. data/lib/puppet/pops/puppet_stack.rb +3 -3
  126. data/lib/puppet/pops/resource/param.rb +5 -1
  127. data/lib/puppet/pops/resource/resource_type_impl.rb +8 -4
  128. data/lib/puppet/pops/resource/resource_type_set.pcore +1 -0
  129. data/lib/puppet/pops/serialization/abstract_reader.rb +19 -2
  130. data/lib/puppet/pops/serialization/abstract_writer.rb +16 -3
  131. data/lib/puppet/pops/serialization/deserializer.rb +5 -1
  132. data/lib/puppet/pops/serialization/extension.rb +2 -0
  133. data/lib/puppet/pops/serialization/json.rb +76 -26
  134. data/lib/puppet/pops/serialization/serializer.rb +5 -1
  135. data/lib/puppet/pops/serialization/time_factory.rb +2 -1
  136. data/lib/puppet/pops/time/timespan.rb +718 -0
  137. data/lib/puppet/pops/time/timestamp.rb +148 -0
  138. data/lib/puppet/pops/types/p_binary_type.rb +220 -0
  139. data/lib/puppet/pops/types/p_object_type.rb +12 -6
  140. data/lib/puppet/pops/types/p_sensitive_type.rb +5 -1
  141. data/lib/puppet/pops/types/p_timespan_type.rb +141 -0
  142. data/lib/puppet/pops/types/p_timestamp_type.rb +69 -0
  143. data/lib/puppet/pops/types/string_converter.rb +62 -0
  144. data/lib/puppet/pops/types/type_asserter.rb +1 -1
  145. data/lib/puppet/pops/types/type_calculator.rb +17 -3
  146. data/lib/puppet/pops/types/type_factory.rb +35 -1
  147. data/lib/puppet/pops/types/type_formatter.rb +64 -11
  148. data/lib/puppet/pops/types/type_mismatch_describer.rb +110 -61
  149. data/lib/puppet/pops/types/type_parser.rb +18 -4
  150. data/lib/puppet/pops/types/types.rb +98 -63
  151. data/lib/puppet/pops/validation.rb +9 -1
  152. data/lib/puppet/pops/validation/checker4_0.rb +7 -0
  153. data/lib/puppet/property.rb +1 -1
  154. data/lib/puppet/provider.rb +3 -6
  155. data/lib/puppet/provider/mcx/mcxcontent.rb +1 -1
  156. data/lib/puppet/provider/mount/parsed.rb +18 -4
  157. data/lib/puppet/provider/nameservice/directoryservice.rb +15 -7
  158. data/lib/puppet/provider/package/gem.rb +6 -1
  159. data/lib/puppet/provider/package/pip.rb +0 -1
  160. data/lib/puppet/provider/package/pkg.rb +5 -1
  161. data/lib/puppet/provider/package/pkgng.rb +1 -1
  162. data/lib/puppet/provider/package/yum.rb +10 -0
  163. data/lib/puppet/provider/service/launchd.rb +1 -0
  164. data/lib/puppet/provider/user/directoryservice.rb +6 -6
  165. data/lib/puppet/provider/yumrepo/inifile.rb +1 -1
  166. data/lib/puppet/provider/zpool/zpool.rb +1 -1
  167. data/lib/puppet/resource.rb +54 -12
  168. data/lib/puppet/resource/capability_finder.rb +15 -9
  169. data/lib/puppet/resource/catalog.rb +25 -6
  170. data/lib/puppet/resource/type.rb +3 -1
  171. data/lib/puppet/settings.rb +1 -1
  172. data/lib/puppet/settings/environment_conf.rb +12 -4
  173. data/lib/puppet/syntax_checkers/base64.rb +41 -0
  174. data/lib/puppet/syntax_checkers/json.rb +0 -2
  175. data/lib/puppet/transaction.rb +6 -0
  176. data/lib/puppet/transaction/additional_resource_generator.rb +5 -0
  177. data/lib/puppet/transaction/report.rb +7 -2
  178. data/lib/puppet/type.rb +2 -1
  179. data/lib/puppet/type/file/checksum.rb +1 -0
  180. data/lib/puppet/type/file/content.rb +4 -4
  181. data/lib/puppet/type/mount.rb +44 -0
  182. data/lib/puppet/type/ssh_authorized_key.rb +1 -1
  183. data/lib/puppet/type/tidy.rb +3 -0
  184. data/lib/puppet/type/user.rb +12 -6
  185. data/lib/puppet/util/log.rb +25 -0
  186. data/lib/puppet/util/plist.rb +8 -3
  187. data/lib/puppet/version.rb +1 -1
  188. data/lib/puppet_x.rb +7 -1
  189. data/spec/integration/application/apply_spec.rb +118 -0
  190. data/spec/integration/parser/compiler_spec.rb +28 -0
  191. data/spec/integration/parser/pcore_resource_spec.rb +40 -3
  192. data/spec/integration/provider/mount_spec.rb +2 -1
  193. data/spec/integration/util/windows/principal_spec.rb +2 -2
  194. data/spec/integration/util/windows/registry_spec.rb +4 -4
  195. data/spec/lib/puppet_spec/compiler.rb +5 -1
  196. data/spec/lib/puppet_spec/unindent.rb +5 -0
  197. data/spec/shared_contexts/types_setup.rb +6 -0
  198. data/spec/shared_examples/rhel_package_provider.rb +16 -0
  199. data/spec/spec_helper.rb +1 -0
  200. data/spec/unit/agent_spec.rb +11 -0
  201. data/spec/unit/application/lookup_spec.rb +94 -3
  202. data/spec/unit/capability_spec.rb +22 -0
  203. data/spec/unit/configurer_spec.rb +8 -0
  204. data/spec/unit/face/epp_face_spec.rb +22 -3
  205. data/spec/unit/functions/assert_type_spec.rb +3 -3
  206. data/spec/unit/functions/binary_file_spec.rb +46 -0
  207. data/spec/unit/functions/break_spec.rb +89 -0
  208. data/spec/unit/{parser/functions → functions}/contain_spec.rb +68 -3
  209. data/spec/unit/functions/find_file_spec.rb +69 -0
  210. data/spec/unit/functions/include_spec.rb +175 -0
  211. data/spec/unit/functions/logging_spec.rb +54 -0
  212. data/spec/unit/functions/lookup_spec.rb +3 -3
  213. data/spec/unit/functions/new_spec.rb +105 -5
  214. data/spec/unit/functions/next_spec.rb +93 -0
  215. data/spec/unit/functions/require_spec.rb +83 -0
  216. data/spec/unit/functions/return_spec.rb +105 -0
  217. data/spec/unit/{parser/functions → functions}/shared.rb +14 -11
  218. data/spec/unit/functions/strftime_spec.rb +152 -0
  219. data/spec/unit/functions4_spec.rb +22 -0
  220. data/spec/unit/indirector/face_spec.rb +10 -2
  221. data/spec/unit/network/http/error_spec.rb +1 -2
  222. data/spec/unit/network/http/handler_spec.rb +6 -5
  223. data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
  224. data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
  225. data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
  226. data/spec/unit/parser/functions/hiera_spec.rb +1 -1
  227. data/spec/unit/parser/functions/lookup_spec.rb +1 -1
  228. data/spec/unit/parser/functions/regsubst_spec.rb +1 -1
  229. data/spec/unit/parser/functions/split_spec.rb +1 -1
  230. data/spec/unit/pops/evaluator/access_ops_spec.rb +81 -1
  231. data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +170 -0
  232. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +29 -4
  233. data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +112 -4
  234. data/spec/unit/pops/loaders/dependency_loader_spec.rb +12 -0
  235. data/spec/unit/pops/loaders/static_loader_spec.rb +0 -26
  236. data/spec/unit/pops/lookup/context_spec.rb +149 -0
  237. data/spec/unit/pops/parser/parse_functions_spec.rb +19 -0
  238. data/spec/unit/pops/parser/parse_lambda_spec.rb +19 -0
  239. data/spec/unit/pops/puppet_stack_spec.rb +1 -1
  240. data/spec/unit/pops/resource/resource_type_impl_spec.rb +74 -0
  241. data/spec/unit/pops/serialization/packer_spec.rb +34 -14
  242. data/spec/unit/pops/serialization/serialization_spec.rb +67 -5
  243. data/spec/unit/pops/time/timespan_spec.rb +121 -0
  244. data/spec/unit/pops/types/p_binary_type_spec.rb +243 -0
  245. data/spec/unit/pops/types/p_object_type_spec.rb +7 -7
  246. data/spec/unit/pops/types/p_sensitive_type_spec.rb +1 -1
  247. data/spec/unit/pops/types/p_timespan_type_spec.rb +273 -0
  248. data/spec/unit/pops/types/p_timestamp_type_spec.rb +311 -0
  249. data/spec/unit/pops/types/p_type_set_type_spec.rb +13 -13
  250. data/spec/unit/pops/types/ruby_generator_spec.rb +12 -12
  251. data/spec/unit/pops/types/string_converter_spec.rb +89 -0
  252. data/spec/unit/pops/types/type_asserter_spec.rb +3 -3
  253. data/spec/unit/pops/types/type_calculator_spec.rb +113 -5
  254. data/spec/unit/pops/types/type_formatter_spec.rb +40 -0
  255. data/spec/unit/pops/types/type_mismatch_describer_spec.rb +49 -38
  256. data/spec/unit/pops/types/type_parser_spec.rb +87 -4
  257. data/spec/unit/pops/types/types_spec.rb +1 -1
  258. data/spec/unit/pops/validator/validator_spec.rb +23 -0
  259. data/spec/unit/provider/mount/parsed_spec.rb +47 -29
  260. data/spec/unit/provider/package/pkg_spec.rb +109 -99
  261. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -0
  262. data/spec/unit/provider/user/aix_spec.rb +1 -1
  263. data/spec/unit/provider/user/directoryservice_spec.rb +101 -30
  264. data/spec/unit/resource/capability_finder_spec.rb +29 -7
  265. data/spec/unit/resource/catalog_spec.rb +127 -0
  266. data/spec/unit/ssl/certificate_request_spec.rb +1 -1
  267. data/spec/unit/transaction/additional_resource_generator_spec.rb +30 -0
  268. data/spec/unit/transaction/persistence_spec.rb +1 -6
  269. data/spec/unit/transaction/report_spec.rb +23 -0
  270. data/spec/unit/transaction_spec.rb +38 -0
  271. data/spec/unit/type/mount_spec.rb +5 -0
  272. data/spec/unit/util/plist_spec.rb +14 -2
  273. metadata +71 -12
  274. data/spec/integration/parser/functions/require_spec.rb +0 -43
  275. data/spec/unit/parser/functions/include_spec.rb +0 -55
  276. data/spec/unit/parser/functions/require_spec.rb +0 -68
@@ -111,6 +111,16 @@ describe TypeParser do
111
111
  expect(the_type_parsed_from(opt_t)).to be_the_type(opt_t)
112
112
  end
113
113
 
114
+ it "parses timespan type" do
115
+ timespan_t = types.timespan
116
+ expect(the_type_parsed_from(timespan_t)).to be_the_type(timespan_t)
117
+ end
118
+
119
+ it "parses timestamp type" do
120
+ timestamp_t = types.timestamp
121
+ expect(the_type_parsed_from(timestamp_t)).to be_the_type(timestamp_t)
122
+ end
123
+
114
124
  it "parses tuple type" do
115
125
  tuple_t = types.tuple([Integer, String])
116
126
  expect(the_type_parsed_from(tuple_t)).to be_the_type(tuple_t)
@@ -248,6 +258,38 @@ describe TypeParser do
248
258
  expect(parser.parse("Collection[1,2]")).to be_the_type(types.collection(types.range(1,2)))
249
259
  end
250
260
 
261
+ it 'parses a timespan type' do
262
+ expect(parser.parse("Timespan")).to be_the_type(types.timespan)
263
+ end
264
+
265
+ it 'parses a timespan type with a lower bound' do
266
+ expect(parser.parse("Timespan[{hours => 3}]")).to be_the_type(types.timespan({'hours' => 3}))
267
+ end
268
+
269
+ it 'parses a timespan type with an upper bound' do
270
+ expect(parser.parse("Timespan[default, {hours => 9}]")).to be_the_type(types.timespan(nil, {'hours' => 9}))
271
+ end
272
+
273
+ it 'parses a timespan type with both lower and upper bounds' do
274
+ expect(parser.parse("Timespan[{hours => 3}, {hours => 9}]")).to be_the_type(types.timespan({'hours' => 3}, {'hours' => 9}))
275
+ end
276
+
277
+ it 'parses a timestamp type' do
278
+ expect(parser.parse("Timestamp")).to be_the_type(types.timestamp)
279
+ end
280
+
281
+ it 'parses a timestamp type with a lower bound' do
282
+ expect(parser.parse("Timestamp['2014-12-12T13:14:15 CET']")).to be_the_type(types.timestamp('2014-12-12T13:14:15 CET'))
283
+ end
284
+
285
+ it 'parses a timestamp type with an upper bound' do
286
+ expect(parser.parse("Timestamp[default, '2014-12-12T13:14:15 CET']")).to be_the_type(types.timestamp(nil, '2014-12-12T13:14:15 CET'))
287
+ end
288
+
289
+ it 'parses a timestamp type with both lower and upper bounds' do
290
+ expect(parser.parse("Timestamp['2014-12-12T13:14:15 CET', '2016-08-23T17:50:00 CET']")).to be_the_type(types.timestamp('2014-12-12T13:14:15 CET', '2016-08-23T17:50:00 CET'))
291
+ end
292
+
251
293
  it 'parses a type type' do
252
294
  expect(parser.parse("Type[Integer]")).to be_the_type(types.type_type(types.integer))
253
295
  end
@@ -257,25 +299,57 @@ describe TypeParser do
257
299
  end
258
300
 
259
301
  it 'parses a callable type' do
260
- expect(parser.parse("Callable")).to be_the_type(types.all_callables())
302
+ t = parser.parse("Callable")
303
+ expect(t).to be_the_type(types.all_callables())
304
+ expect(t.return_type).to be_nil
261
305
  end
262
306
 
263
307
  it 'parses a parameterized callable type' do
264
- expect(parser.parse("Callable[String, Integer]")).to be_the_type(types.callable(String, Integer))
308
+ t = parser.parse("Callable[String, Integer]")
309
+ expect(t).to be_the_type(types.callable(String, Integer))
310
+ expect(t.return_type).to be_nil
265
311
  end
266
312
 
267
313
  it 'parses a parameterized callable type with min/max' do
268
- expect(parser.parse("Callable[String, Integer, 1, default]")).to be_the_type(types.callable(String, Integer, 1, :default))
314
+ t = parser.parse("Callable[String, Integer, 1, default]")
315
+ expect(t).to be_the_type(types.callable(String, Integer, 1, :default))
316
+ expect(t.return_type).to be_nil
269
317
  end
270
318
 
271
319
  it 'parses a parameterized callable type with block' do
272
- expect(parser.parse("Callable[String, Callable[Boolean]]")).to be_the_type(types.callable(String, types.callable(true)))
320
+ t = parser.parse("Callable[String, Callable[Boolean]]")
321
+ expect(t).to be_the_type(types.callable(String, types.callable(true)))
322
+ expect(t.return_type).to be_nil
323
+ end
324
+
325
+ it 'parses a callable with no parameters and return type' do
326
+ expect(parser.parse("Callable[[],Float]")).to be_the_type(types.callable([],Float))
327
+ end
328
+
329
+ it 'parses a parameterized callable type with return type' do
330
+ expect(parser.parse("Callable[[String, Integer],Float]")).to be_the_type(types.callable([String, Integer],Float))
331
+ end
332
+
333
+ it 'parses a parameterized callable type with min/max and return type' do
334
+ expect(parser.parse("Callable[[String, Integer, 1, default],Float]")).to be_the_type(types.callable([String, Integer, 1, :default], Float))
335
+ end
336
+
337
+ it 'parses a parameterized callable type with block and return type' do
338
+ expect(parser.parse("Callable[[String, Callable[Boolean]],Float]")).to be_the_type(types.callable([String, types.callable(true)], Float))
273
339
  end
274
340
 
275
341
  it 'parses a parameterized callable type with 0 min/max' do
276
342
  t = parser.parse("Callable[0,0]")
277
343
  expect(t).to be_the_type(types.callable(0,0))
278
344
  expect(t.param_types.types).to be_empty
345
+ expect(t.return_type).to be_nil
346
+ end
347
+
348
+ it 'parses a parameterized callable type with 0 min/max and return_type' do
349
+ t = parser.parse("Callable[[0,0],Float]")
350
+ expect(t).to be_the_type(types.callable([0,0],Float))
351
+ expect(t.param_types.types).to be_empty
352
+ expect(t.return_type).to be_the_type(types.float)
279
353
  end
280
354
 
281
355
  it 'parses a parameterized callable type with >0 min/max' do
@@ -283,6 +357,15 @@ describe TypeParser do
283
357
  expect(t).to be_the_type(types.callable(0,1))
284
358
  # Contains a Unit type to indicate "called with what you accept"
285
359
  expect(t.param_types.types[0]).to be_the_type(PUnitType.new())
360
+ expect(t.return_type).to be_nil
361
+ end
362
+
363
+ it 'parses a parameterized callable type with >0 min/max and a return type' do
364
+ t = parser.parse("Callable[[0,1],Float]")
365
+ expect(t).to be_the_type(types.callable([0,1], Float))
366
+ # Contains a Unit type to indicate "called with what you accept"
367
+ expect(t.param_types.types[0]).to be_the_type(PUnitType.new())
368
+ expect(t.return_type).to be_the_type(types.float)
286
369
  end
287
370
 
288
371
  it 'parses all known literals' do
@@ -440,7 +440,7 @@ describe 'Puppet Type System' do
440
440
  type Foo = Variant[Foo,String,Integer]
441
441
  assert_type(Foo, /x/)
442
442
  CODE
443
- expect { eval_and_collect_notices(code) }.to raise_error(/expected a value of type String or Integer, got Regexp/)
443
+ expect { eval_and_collect_notices(code) }.to raise_error(/expects a value of type String or Integer, got Regexp/)
444
444
  end
445
445
 
446
446
  it 'will handle a scalar correctly in combinations of nested aliased variants' do
@@ -440,6 +440,29 @@ describe "validating 4x" do
440
440
  end
441
441
  end
442
442
 
443
+ context 'that are functions' do
444
+ it 'accepts typed parameters' do
445
+ source = <<-CODE
446
+ function f(Integer $a) { $a }
447
+ CODE
448
+ expect(validate(parse(source))).not_to have_any_issues
449
+ end
450
+
451
+ it 'accepts return types' do
452
+ source = <<-CODE
453
+ function f() >> Integer { 42 }
454
+ CODE
455
+ expect(validate(parse(source))).not_to have_any_issues
456
+ end
457
+
458
+ it 'accepts block with return types' do
459
+ source = <<-CODE
460
+ map([1,2]) |Integer $x| >> Integer { $x + 3 }
461
+ CODE
462
+ expect(validate(parse(source))).not_to have_any_issues
463
+ end
464
+ end
465
+
443
466
  context 'that are type mappings' do
444
467
  it 'accepts a valid type mapping expression' do
445
468
  source = <<-CODE
@@ -115,6 +115,7 @@ FSTAB
115
115
  describe "mountinstances" do
116
116
  it "should get name from mountoutput found on Solaris" do
117
117
  Facter.stubs(:value).with(:osfamily).returns 'Solaris'
118
+ Facter.stubs(:value).with(:kernel).returns 'SunOS'
118
119
  described_class.stubs(:mountcmd).returns(File.read(my_fixture('solaris.mount')))
119
120
  mounts = described_class.mountinstances
120
121
  expect(mounts.size).to eq(6)
@@ -128,6 +129,7 @@ FSTAB
128
129
 
129
130
  it "should get name from mountoutput found on HP-UX" do
130
131
  Facter.stubs(:value).with(:osfamily).returns 'HP-UX'
132
+ Facter.stubs(:value).with(:kernel).returns 'HP-UX'
131
133
  described_class.stubs(:mountcmd).returns(File.read(my_fixture('hpux.mount')))
132
134
  mounts = described_class.mountinstances
133
135
  expect(mounts.size).to eq(17)
@@ -150,32 +152,35 @@ FSTAB
150
152
  expect(mounts[16]).to eq({ :name => '/ghost', :mounted => :yes })
151
153
  end
152
154
 
153
- it "should get name from mountoutput found on Darwin" do
155
+ it "should get name and mount options from mountoutput found on Darwin" do
154
156
  Facter.stubs(:value).with(:osfamily).returns 'Darwin'
157
+ Facter.stubs(:value).with(:kernel).returns 'Darwin'
155
158
  described_class.stubs(:mountcmd).returns(File.read(my_fixture('darwin.mount')))
156
159
  mounts = described_class.mountinstances
157
160
  expect(mounts.size).to eq(6)
158
- expect(mounts[0]).to eq({ :name => '/', :mounted => :yes })
159
- expect(mounts[1]).to eq({ :name => '/dev', :mounted => :yes })
160
- expect(mounts[2]).to eq({ :name => '/net', :mounted => :yes })
161
- expect(mounts[3]).to eq({ :name => '/home', :mounted => :yes })
162
- expect(mounts[4]).to eq({ :name => '/usr', :mounted => :yes })
163
- expect(mounts[5]).to eq({ :name => '/ghost', :mounted => :yes })
161
+ expect(mounts[0]).to eq({ :name => '/', :mounted => :yes, :live_options=>"hfs, local, journaled"})
162
+ expect(mounts[1]).to eq({ :name => '/dev', :mounted => :yes, :live_options=>"devfs, local, nobrowse"})
163
+ expect(mounts[2]).to eq({ :name => '/net', :mounted => :yes, :live_options=>"autofs, nosuid, automounted, nobrowse"})
164
+ expect(mounts[3]).to eq({ :name => '/home', :mounted => :yes, :mounted=>:yes, :live_options=>"autofs, automounted, nobrowse"})
165
+ expect(mounts[4]).to eq({ :name => '/usr', :mounted => :yes, :mounted=>:yes, :live_options=>"hfs, local, journaled"})
166
+ expect(mounts[5]).to eq({ :name => '/ghost', :mounted => :yes, :live_options => "hfs, local, journaled"})
164
167
  end
165
168
 
166
- it "should get name from mountoutput found on Linux" do
169
+ it "should get name and mount options from mountoutput found on Linux" do
167
170
  Facter.stubs(:value).with(:osfamily).returns 'Gentoo'
171
+ Facter.stubs(:value).with(:kernel).returns 'Linux'
168
172
  described_class.stubs(:mountcmd).returns(File.read(my_fixture('linux.mount')))
169
173
  mounts = described_class.mountinstances
170
- expect(mounts[0]).to eq({ :name => '/', :mounted => :yes })
171
- expect(mounts[1]).to eq({ :name => '/lib64/rc/init.d', :mounted => :yes })
172
- expect(mounts[2]).to eq({ :name => '/sys', :mounted => :yes })
173
- expect(mounts[3]).to eq({ :name => '/usr/portage', :mounted => :yes })
174
- expect(mounts[4]).to eq({ :name => '/ghost', :mounted => :yes })
174
+ expect(mounts[0]).to eq({ :name => '/', :mounted => :yes, :live_options=>"rw,noatime"})
175
+ expect(mounts[1]).to eq({ :name => '/lib64/rc/init.d', :mounted => :yes, :live_options => "rw,nosuid,nodev,noexec,relatime,size=1024k,mode=755" })
176
+ expect(mounts[2]).to eq({ :name => '/sys', :mounted => :yes, :live_options => "rw,nosuid,nodev,noexec,relatime"})
177
+ expect(mounts[3]).to eq({ :name => '/usr/portage', :mounted => :yes, :live_options => "rw" })
178
+ expect(mounts[4]).to eq({ :name => '/ghost', :mounted => :yes, :live_options => "rw" })
175
179
  end
176
180
 
177
181
  it "should get name from mountoutput found on AIX" do
178
182
  Facter.stubs(:value).with(:osfamily).returns 'AIX'
183
+ Facter.stubs(:value).with(:kernel).returns 'AIX'
179
184
  described_class.stubs(:mountcmd).returns(File.read(my_fixture('aix.mount')))
180
185
  mounts = described_class.mountinstances
181
186
  expect(mounts[0]).to eq({ :name => '/', :mounted => :yes })
@@ -224,29 +229,42 @@ FSTAB
224
229
  platform != 'solaris' or
225
230
  skip "We need to stub the operatingsystem fact at load time, but can't"
226
231
  end
227
-
228
- # Stub the mount output to our fixture.
229
- begin
230
- mount = my_fixture(platform + '.mount')
231
- described_class.stubs(:mountcmd).returns File.read(mount)
232
- rescue
233
- skip "is #{platform}.mount missing at this point?"
234
- end
235
-
236
- # Note: we have to stub default_target before creating resources
237
- # because it is used by Puppet::Type::Mount.new to populate the
238
- # :target property.
239
- described_class.stubs(:default_target).returns fstab
240
- @retrieve = described_class.instances.collect { |prov| {:name => prov.get(:name), :ensure => prov.get(:ensure)}}
241
232
  end
242
233
 
243
234
  # Following mountpoint are present in all fstabs/mountoutputs
244
235
  describe "on other platforms than Solaris", :if => Facter.value(:osfamily) != 'Solaris' do
245
- it "should include unmounted resources" do
236
+ before :each do
237
+ # Stub the mount output to our fixture.
238
+ begin
239
+ mount = my_fixture(platform + '.mount')
240
+ described_class.stubs(:mountcmd).returns File.read(mount)
241
+ rescue
242
+ skip "is #{platform}.mount missing at this point?"
243
+ end
244
+
245
+ # Note: we have to stub default_target before creating resources
246
+ # because it is used by Puppet::Type::Mount.new to populate the
247
+ # :target property.
248
+ described_class.stubs(:default_target).returns fstab
249
+
250
+ platforms = {
251
+ 'linux' => ['Gentoo', 'Linux'],
252
+ 'freebsd' => ['BSD', 'BSD'],
253
+ 'openbsd' => ['BSD', 'BSD'],
254
+ 'netbsd' => ['BSd', 'BSD']
255
+ }
256
+ Facter.stubs(:value).with(:osfamily).returns(platforms[platform][0])
257
+ Facter.stubs(:value).with(:kernel).returns(platforms[platform][1])
258
+
259
+ @retrieve = described_class.instances.collect { |prov| {:name => prov.get(:name), :ensure => prov.get(:ensure)}}
260
+ end
261
+
262
+ it "should include mounted resources" do
246
263
  expect(@retrieve).to include(:name => '/', :ensure => :mounted)
247
264
  end
248
265
 
249
- it "should include mounted resources" do
266
+ it "should include unmounted resources" do
267
+ @retrieve = described_class.instances.collect { |prov| {:name => prov.get(:name), :ensure => prov.get(:ensure)}}
250
268
  expect(@retrieve).to include(:name => '/boot', :ensure => :unmounted)
251
269
  end
252
270
 
@@ -201,105 +201,115 @@ describe Puppet::Type.type(:package).provider(:pkg) do
201
201
  end
202
202
 
203
203
  context ":install" do
204
- it "should accept all licenses" do
205
- provider.expects(:query).with().returns({:ensure => :absent})
206
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'install', '--accept', 'dummy'], {:failonfail => false, :combine => true}).returns ''
207
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true}).returns ''
208
- $CHILD_STATUS.stubs(:exitstatus).returns 0
209
- provider.install
210
- end
211
-
212
- it "should install specific version(1)" do
213
- # Should install also check if the version installed is the same version we are asked to install? or should we rely on puppet for that?
214
- resource[:ensure] = '0.0.7,5.11-0.151006:20131230T130000Z'
215
- $CHILD_STATUS.stubs(:exitstatus).returns 0
216
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
217
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'list', '-Hv', 'dummy'], {:failonfail => false, :combine => true}).returns 'pkg://foo/dummy@0.0.6,5.11-0.151006:20131230T130000Z installed -----'
218
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', '--accept', 'dummy@0.0.7,5.11-0.151006:20131230T130000Z'], {:failonfail => false, :combine => true}).returns ''
219
- provider.install
220
- end
221
-
222
- it "should install specific version(2)" do
223
- resource[:ensure] = '0.0.8'
224
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
225
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'list', '-Hv', 'dummy'], {:failonfail => false, :combine => true}).returns 'pkg://foo/dummy@0.0.7,5.11-0.151006:20131230T130000Z installed -----'
226
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', '--accept', 'dummy@0.0.8'], {:failonfail => false, :combine => true}).returns ''
227
- $CHILD_STATUS.stubs(:exitstatus).returns 0
228
- provider.install
229
- end
230
-
231
- it "should downgrade to specific version" do
232
- resource[:ensure] = '0.0.7'
233
- provider.expects(:query).with().returns({:ensure => '0.0.8,5.11-0.151106:20131230T130000Z'})
234
- $CHILD_STATUS.stubs(:exitstatus).returns 0
235
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
236
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', '--accept', 'dummy@0.0.7'], {:failonfail => false, :combine => true}).returns ''
237
- provider.install
238
- end
239
-
240
- it "should install any if version is not specified" do
241
- resource[:ensure] = :present
242
- provider.expects(:query).with().returns({:ensure => :absent})
243
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'install', '--accept', 'dummy'], {:failonfail => false, :combine => true}).returns ''
244
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
245
- $CHILD_STATUS.stubs(:exitstatus).returns 0
246
- provider.install
247
- end
248
-
249
- it "should install if no version was previously installed, and a specific version was requested" do
250
- resource[:ensure] = '0.0.7'
251
- provider.expects(:query).with().returns({:ensure => :absent})
252
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
253
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'install', '--accept', 'dummy@0.0.7'], {:failonfail => false, :combine => true}).returns ''
254
- $CHILD_STATUS.stubs(:exitstatus).returns 0
255
- provider.install
256
- end
257
-
258
- it "installs the latest matching version when given implicit version, and none are installed" do
259
- resource[:ensure] = '1.0-0.151006'
260
- is = :absent
261
- provider.expects(:query).with().returns({:ensure => is})
262
- described_class.expects(:pkg).with(:list, '-Hvfa', 'dummy@1.0-0.151006').returns File.read(my_fixture('dummy_implicit_version'))
263
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'install', '-n', 'dummy@1.0,5.11-0.151006:20140220T084443Z'], {:failonfail => false, :combine => true})
264
- provider.expects(:unhold).with()
265
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'install', '--accept', 'dummy@1.0,5.11-0.151006:20140220T084443Z'], {:failonfail => false, :combine => true})
266
- $CHILD_STATUS.stubs(:exitstatus).returns 0
267
- provider.insync?(is)
268
- provider.install
269
- end
270
-
271
- it "updates to the latest matching version when given implicit version" do
272
- resource[:ensure] = '1.0-0.151006'
273
- is = '1.0,5.11-0.151006:20140219T191204Z'
274
- provider.expects(:query).with().returns({:ensure => is})
275
- described_class.expects(:pkg).with(:list, '-Hvfa', 'dummy@1.0-0.151006').returns File.read(my_fixture('dummy_implicit_version'))
276
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', '-n', 'dummy@1.0,5.11-0.151006:20140220T084443Z'], {:failonfail => false, :combine => true})
277
- provider.expects(:unhold).with()
278
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', '--accept', 'dummy@1.0,5.11-0.151006:20140220T084443Z'], {:failonfail => false, :combine => true})
279
- $CHILD_STATUS.stubs(:exitstatus).returns 0
280
- provider.insync?(is)
281
- provider.install
282
- end
283
-
284
- it "issues a warning when an implicit version number is used, and in sync" do
285
- resource[:ensure] = '1.0-0.151006'
286
- is = '1.0,5.11-0.151006:20140220T084443Z'
287
- provider.expects(:warning).with("Implicit version 1.0-0.151006 has 3 possible matches")
288
- described_class.expects(:pkg).with(:list, '-Hvfa', 'dummy@1.0-0.151006').returns File.read(my_fixture('dummy_implicit_version'))
289
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', '-n', 'dummy@1.0,5.11-0.151006:20140220T084443Z'], {:failonfail => false, :combine => true})
290
- $CHILD_STATUS.stubs(:exitstatus).returns 4
291
- provider.insync?(is)
292
- end
293
-
294
- it "issues a warning when choosing a version number for an implicit match" do
295
- resource[:ensure] = '1.0-0.151006'
296
- is = :absent
297
- provider.expects(:warning).with("Implicit version 1.0-0.151006 has 3 possible matches")
298
- provider.expects(:warning).with("Selecting version '1.0,5.11-0.151006:20140220T084443Z' for implicit '1.0-0.151006'")
299
- described_class.expects(:pkg).with(:list, '-Hvfa', 'dummy@1.0-0.151006').returns File.read(my_fixture('dummy_implicit_version'))
300
- Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'install', '-n', 'dummy@1.0,5.11-0.151006:20140220T084443Z'], {:failonfail => false, :combine => true})
301
- $CHILD_STATUS.stubs(:exitstatus).returns 0
302
- provider.insync?(is)
204
+ [
205
+ { :osrel => '11.0', :flags => ['--accept'] },
206
+ { :osrel => '11.2', :flags => ['--accept', '--sync-actuators-timeout', '900'] },
207
+ ].each do |hash|
208
+ context "with :operatingsystemrelease #{hash[:osrel]}" do
209
+ before :each do
210
+ Facter.stubs(:value).with(:operatingsystemrelease).returns hash[:osrel]
211
+ end
212
+ it "should accept all licenses" do
213
+ provider.expects(:query).with().returns({:ensure => :absent})
214
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'install', *hash[:flags], 'dummy'], {:failonfail => false, :combine => true}).returns ''
215
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true}).returns ''
216
+ $CHILD_STATUS.stubs(:exitstatus).returns 0
217
+ provider.install
218
+ end
219
+
220
+ it "should install specific version(1)" do
221
+ # Should install also check if the version installed is the same version we are asked to install? or should we rely on puppet for that?
222
+ resource[:ensure] = '0.0.7,5.11-0.151006:20131230T130000Z'
223
+ $CHILD_STATUS.stubs(:exitstatus).returns 0
224
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
225
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'list', '-Hv', 'dummy'], {:failonfail => false, :combine => true}).returns 'pkg://foo/dummy@0.0.6,5.11-0.151006:20131230T130000Z installed -----'
226
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', *hash[:flags], 'dummy@0.0.7,5.11-0.151006:20131230T130000Z'], {:failonfail => false, :combine => true}).returns ''
227
+ provider.install
228
+ end
229
+
230
+ it "should install specific version(2)" do
231
+ resource[:ensure] = '0.0.8'
232
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
233
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'list', '-Hv', 'dummy'], {:failonfail => false, :combine => true}).returns 'pkg://foo/dummy@0.0.7,5.11-0.151006:20131230T130000Z installed -----'
234
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', *hash[:flags], 'dummy@0.0.8'], {:failonfail => false, :combine => true}).returns ''
235
+ $CHILD_STATUS.stubs(:exitstatus).returns 0
236
+ provider.install
237
+ end
238
+
239
+ it "should downgrade to specific version" do
240
+ resource[:ensure] = '0.0.7'
241
+ provider.expects(:query).with().returns({:ensure => '0.0.8,5.11-0.151106:20131230T130000Z'})
242
+ $CHILD_STATUS.stubs(:exitstatus).returns 0
243
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
244
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', *hash[:flags], 'dummy@0.0.7'], {:failonfail => false, :combine => true}).returns ''
245
+ provider.install
246
+ end
247
+
248
+ it "should install any if version is not specified" do
249
+ resource[:ensure] = :present
250
+ provider.expects(:query).with().returns({:ensure => :absent})
251
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'install', *hash[:flags], 'dummy'], {:failonfail => false, :combine => true}).returns ''
252
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
253
+ $CHILD_STATUS.stubs(:exitstatus).returns 0
254
+ provider.install
255
+ end
256
+
257
+ it "should install if no version was previously installed, and a specific version was requested" do
258
+ resource[:ensure] = '0.0.7'
259
+ provider.expects(:query).with().returns({:ensure => :absent})
260
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'unfreeze', 'dummy'], {:failonfail => false, :combine => true})
261
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'install', *hash[:flags], 'dummy@0.0.7'], {:failonfail => false, :combine => true}).returns ''
262
+ $CHILD_STATUS.stubs(:exitstatus).returns 0
263
+ provider.install
264
+ end
265
+
266
+ it "installs the latest matching version when given implicit version, and none are installed" do
267
+ resource[:ensure] = '1.0-0.151006'
268
+ is = :absent
269
+ provider.expects(:query).with().returns({:ensure => is})
270
+ described_class.expects(:pkg).with(:list, '-Hvfa', 'dummy@1.0-0.151006').returns File.read(my_fixture('dummy_implicit_version'))
271
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'install', '-n', 'dummy@1.0,5.11-0.151006:20140220T084443Z'], {:failonfail => false, :combine => true})
272
+ provider.expects(:unhold).with()
273
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'install', *hash[:flags], 'dummy@1.0,5.11-0.151006:20140220T084443Z'], {:failonfail => false, :combine => true})
274
+ $CHILD_STATUS.stubs(:exitstatus).returns 0
275
+ provider.insync?(is)
276
+ provider.install
277
+ end
278
+
279
+ it "updates to the latest matching version when given implicit version" do
280
+ resource[:ensure] = '1.0-0.151006'
281
+ is = '1.0,5.11-0.151006:20140219T191204Z'
282
+ provider.expects(:query).with().returns({:ensure => is})
283
+ described_class.expects(:pkg).with(:list, '-Hvfa', 'dummy@1.0-0.151006').returns File.read(my_fixture('dummy_implicit_version'))
284
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', '-n', 'dummy@1.0,5.11-0.151006:20140220T084443Z'], {:failonfail => false, :combine => true})
285
+ provider.expects(:unhold).with()
286
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', *hash[:flags], 'dummy@1.0,5.11-0.151006:20140220T084443Z'], {:failonfail => false, :combine => true})
287
+ $CHILD_STATUS.stubs(:exitstatus).returns 0
288
+ provider.insync?(is)
289
+ provider.install
290
+ end
291
+
292
+ it "issues a warning when an implicit version number is used, and in sync" do
293
+ resource[:ensure] = '1.0-0.151006'
294
+ is = '1.0,5.11-0.151006:20140220T084443Z'
295
+ provider.expects(:warning).with("Implicit version 1.0-0.151006 has 3 possible matches")
296
+ described_class.expects(:pkg).with(:list, '-Hvfa', 'dummy@1.0-0.151006').returns File.read(my_fixture('dummy_implicit_version'))
297
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'update', '-n', 'dummy@1.0,5.11-0.151006:20140220T084443Z'], {:failonfail => false, :combine => true})
298
+ $CHILD_STATUS.stubs(:exitstatus).returns 4
299
+ provider.insync?(is)
300
+ end
301
+
302
+ it "issues a warning when choosing a version number for an implicit match" do
303
+ resource[:ensure] = '1.0-0.151006'
304
+ is = :absent
305
+ provider.expects(:warning).with("Implicit version 1.0-0.151006 has 3 possible matches")
306
+ provider.expects(:warning).with("Selecting version '1.0,5.11-0.151006:20140220T084443Z' for implicit '1.0-0.151006'")
307
+ described_class.expects(:pkg).with(:list, '-Hvfa', 'dummy@1.0-0.151006').returns File.read(my_fixture('dummy_implicit_version'))
308
+ Puppet::Util::Execution.expects(:execute).with(['/bin/pkg', 'install', '-n', 'dummy@1.0,5.11-0.151006:20140220T084443Z'], {:failonfail => false, :combine => true})
309
+ $CHILD_STATUS.stubs(:exitstatus).returns 0
310
+ provider.insync?(is)
311
+ end
312
+ end
303
313
  end
304
314
  end
305
315