puppet 2.6.7 → 2.6.8

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 (80) hide show
  1. data/CHANGELOG +49 -0
  2. data/install.rb +6 -2
  3. data/lib/puppet.rb +1 -1
  4. data/lib/puppet/application.rb +16 -8
  5. data/lib/puppet/application/agent.rb +2 -0
  6. data/lib/puppet/application/apply.rb +3 -0
  7. data/lib/puppet/application/master.rb +1 -1
  8. data/lib/puppet/configurer.rb +10 -1
  9. data/lib/puppet/defaults.rb +9 -0
  10. data/lib/puppet/file_serving/fileset.rb +1 -0
  11. data/lib/puppet/indirector/exec.rb +1 -2
  12. data/lib/puppet/indirector/report/yaml.rb +11 -0
  13. data/lib/puppet/node/environment.rb +1 -1
  14. data/lib/puppet/parameter.rb +2 -0
  15. data/lib/puppet/parameter/path.rb +42 -0
  16. data/lib/puppet/parser/compiler.rb +1 -1
  17. data/lib/puppet/parser/lexer.rb +3 -2
  18. data/lib/puppet/parser/parser_support.rb +0 -1
  19. data/lib/puppet/provider/exec/posix.rb +112 -0
  20. data/lib/puppet/provider/exec/shell.rb +17 -0
  21. data/lib/puppet/provider/group/groupadd.rb +3 -0
  22. data/lib/puppet/provider/nameservice/#directoryservice.rb# +519 -0
  23. data/lib/puppet/provider/package/gem.rb +2 -2
  24. data/lib/puppet/provider/package/macports.rb +106 -0
  25. data/lib/puppet/provider/service/debian.rb +6 -2
  26. data/lib/puppet/rails/inventory_node.rb +5 -0
  27. data/lib/puppet/reference/#providers.rb# +123 -0
  28. data/lib/puppet/resource/type_collection.rb +6 -1
  29. data/lib/puppet/simple_graph.rb +1 -1
  30. data/lib/puppet/transaction.rb +1 -1
  31. data/lib/puppet/transaction/report.rb +28 -10
  32. data/lib/puppet/type/cron.rb +3 -1
  33. data/lib/puppet/type/exec.rb +30 -167
  34. data/lib/puppet/type/file.rb +12 -1
  35. data/lib/puppet/type/file/source.rb +1 -0
  36. data/lib/puppet/type/group.rb +11 -1
  37. data/lib/puppet/type/service.rb +19 -11
  38. data/lib/puppet/util/command_line.rb +15 -12
  39. data/lib/puppet/util/command_line/puppetrun +0 -1
  40. data/lib/puppet/util/loadedfile.rb +1 -5
  41. data/lib/puppet/util/metric.rb +3 -5
  42. data/lib/puppet/util/plugins.rb +82 -0
  43. data/spec/integration/configurer_spec.rb +38 -5
  44. data/spec/integration/transaction_spec.rb +43 -42
  45. data/spec/lib/puppet_spec/verbose.rb +9 -0
  46. data/spec/shared_behaviours/path_parameters.rb +185 -0
  47. data/spec/spec_helper.rb +6 -0
  48. data/spec/unit/application/agent_spec.rb +7 -0
  49. data/spec/unit/application/apply_spec.rb +6 -0
  50. data/spec/unit/application/master_spec.rb +2 -2
  51. data/spec/unit/configurer_spec.rb +48 -0
  52. data/spec/unit/file_serving/fileset_spec.rb +8 -0
  53. data/spec/unit/indirector/certificate_status/#file_spec.rb# +188 -0
  54. data/spec/unit/indirector/exec_spec.rb +2 -3
  55. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +5 -1
  56. data/spec/unit/indirector/report/yaml_spec.rb +38 -0
  57. data/spec/unit/node/environment_spec.rb +15 -14
  58. data/spec/unit/parameter/path_spec.rb +24 -0
  59. data/spec/unit/parser/compiler_spec.rb +1 -2
  60. data/spec/unit/parser/lexer_spec.rb +12 -0
  61. data/spec/unit/provider/exec/posix_spec.rb +120 -0
  62. data/spec/unit/provider/exec/shell_spec.rb +50 -0
  63. data/spec/unit/provider/group/groupadd_spec.rb +11 -1
  64. data/spec/unit/provider/package/gem_spec.rb +11 -1
  65. data/spec/unit/provider/package/macports_spec.rb +122 -0
  66. data/spec/unit/provider/service/debian_spec.rb +14 -2
  67. data/spec/unit/resource/#type_collection_spec.rb# +463 -0
  68. data/spec/unit/resource/type_collection_spec.rb +21 -17
  69. data/spec/unit/transaction/report_spec.rb +13 -2
  70. data/spec/unit/type/cron_spec.rb +466 -18
  71. data/spec/unit/type/exec_spec.rb +633 -106
  72. data/spec/unit/type/file/source_spec.rb +1 -0
  73. data/spec/unit/type/group_spec.rb +8 -1
  74. data/spec/unit/type_spec.rb +1 -1
  75. data/spec/unit/util/loadedfile_spec.rb +7 -0
  76. data/spec/unit/util/rdoc/parser_spec.rb +2 -1
  77. data/tasks/rake/git_workflow.rake +3 -1
  78. data/test/ral/type/exec.rb +87 -176
  79. metadata +21 -5
  80. data/lib/puppet/provider/package/darwinport.rb +0 -86
@@ -52,8 +52,20 @@ describe provider_class do
52
52
  end
53
53
 
54
54
  describe "when disabling" do
55
- it "should call update-rc.d twice" do
56
- @provider.expects(:update_rc).twice
55
+ it "should be able to disable services with newer sysv-rc versions" do
56
+ @provider.stubs(:`).with("dpkg --compare-versions $(dpkg-query -W --showformat '${Version}' sysv-rc) ge 2.88 ; echo $?").returns "0"
57
+
58
+ @provider.expects(:update_rc).with(@resource[:name], "disable")
59
+
60
+ @provider.disable
61
+ end
62
+
63
+ it "should be able to enable services with older sysv-rc versions" do
64
+ @provider.stubs(:`).with("dpkg --compare-versions $(dpkg-query -W --showformat '${Version}' sysv-rc) ge 2.88 ; echo $?").returns "1"
65
+
66
+ @provider.expects(:update_rc).with("-f", @resource[:name], "remove")
67
+ @provider.expects(:update_rc).with(@resource[:name], "stop", "00", "1", "2", "3", "4", "5", "6", ".")
68
+
57
69
  @provider.disable
58
70
  end
59
71
  end
@@ -0,0 +1,463 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + '/../../spec_helper'
4
+
5
+ require 'puppet/resource/type_collection'
6
+ require 'puppet/resource/type'
7
+
8
+ describe Puppet::Resource::TypeCollection do
9
+ include PuppetSpec::Files
10
+ before do
11
+ @instance = Puppet::Resource::Type.new(:hostclass, "foo")
12
+ @code = Puppet::Resource::TypeCollection.new("env")
13
+ end
14
+
15
+ it "should require an environment at initialization" do
16
+ env = Puppet::Node::Environment.new("testing")
17
+ Puppet::Resource::TypeCollection.new(env).environment.should equal(env)
18
+ end
19
+
20
+ it "should convert the environment into an environment instance if a string is provided" do
21
+ env = Puppet::Node::Environment.new("testing")
22
+ Puppet::Resource::TypeCollection.new("testing").environment.should equal(env)
23
+ end
24
+
25
+ it "should create a 'loader' at initialization" do
26
+ Puppet::Resource::TypeCollection.new("testing").loader.should be_instance_of(Puppet::Parser::TypeLoader)
27
+ end
28
+
29
+ it "should be able to add a resource type" do
30
+ Puppet::Resource::TypeCollection.new("env").should respond_to(:add)
31
+ end
32
+
33
+ it "should consider '<<' to be an alias to 'add' but should return self" do
34
+ loader = Puppet::Resource::TypeCollection.new("env")
35
+ loader.expects(:add).with "foo"
36
+ loader.expects(:add).with "bar"
37
+ loader << "foo" << "bar"
38
+ end
39
+
40
+ it "should set itself as the code collection for added resource types" do
41
+ loader = Puppet::Resource::TypeCollection.new("env")
42
+
43
+ node = Puppet::Resource::Type.new(:node, "foo")
44
+
45
+ @code.add(node)
46
+ @code.node("foo").should equal(node)
47
+
48
+ node.resource_type_collection.should equal(@code)
49
+ end
50
+
51
+ it "should store node resource types as nodes" do
52
+ node = Puppet::Resource::Type.new(:node, "foo")
53
+
54
+ @code.add(node)
55
+ @code.node("foo").should equal(node)
56
+ end
57
+
58
+ it "should store hostclasses as hostclasses" do
59
+ klass = Puppet::Resource::Type.new(:hostclass, "foo")
60
+
61
+ @code.add(klass)
62
+ @code.hostclass("foo").should equal(klass)
63
+ end
64
+
65
+ it "should store definitions as definitions" do
66
+ define = Puppet::Resource::Type.new(:definition, "foo")
67
+
68
+ @code.add(define)
69
+ @code.definition("foo").should equal(define)
70
+ end
71
+
72
+ it "should merge new classes with existing classes of the same name" do
73
+ loader = Puppet::Resource::TypeCollection.new("env")
74
+ first = Puppet::Resource::Type.new(:hostclass, "foo")
75
+ second = Puppet::Resource::Type.new(:hostclass, "foo")
76
+ loader.add first
77
+ first.expects(:merge).with(second)
78
+ loader.add(second)
79
+ end
80
+
81
+ it "should remove all nodes, classes, and definitions when cleared" do
82
+ loader = Puppet::Resource::TypeCollection.new("env")
83
+ loader.add Puppet::Resource::Type.new(:hostclass, "class")
84
+ loader.add Puppet::Resource::Type.new(:definition, "define")
85
+ loader.add Puppet::Resource::Type.new(:node, "node")
86
+
87
+ loader.clear
88
+ loader.hostclass("class").should be_nil
89
+ loader.definition("define").should be_nil
90
+ loader.node("node").should be_nil
91
+ end
92
+
93
+ describe "when looking up names" do
94
+ before do
95
+ @type = Puppet::Resource::Type.new(:hostclass, "ns::klass")
96
+ end
97
+
98
+ it "should support looking up with multiple namespaces" do
99
+ @code.add @type
100
+ @code.find_hostclass(%w{boo baz ns}, "klass").should equal(@type)
101
+ end
102
+
103
+ it "should not attempt to import anything when the type is already defined" do
104
+ @code.add @type
105
+ @code.loader.expects(:import).never
106
+ @code.find_hostclass(%w{ns}, "klass").should equal(@type)
107
+ end
108
+
109
+ describe "that need to be loaded" do
110
+ it "should use the loader to load the files" do
111
+ @code.loader.expects(:load_until).with(["ns"], "klass")
112
+ @code.find_or_load(["ns"], "klass", :hostclass)
113
+ end
114
+
115
+ it "should downcase the name and downcase and array-fy the namespaces before passing to the loader" do
116
+ @code.loader.expects(:load_until).with(["ns"], "klass")
117
+ @code.find_or_load("Ns", "Klass", :hostclass)
118
+ end
119
+
120
+ it "should attempt to find the type when the loader yields" do
121
+ @code.loader.expects(:load_until).yields
122
+ @code.expects(:find).with(["ns"], "klass", :hostclass).times(2).returns(false).then.returns(true)
123
+ @code.find_or_load("ns", "klass", :hostclass)
124
+ end
125
+
126
+ it "should return the result of 'load_until'" do
127
+ @code.loader.expects(:load_until).returns "foo"
128
+ @code.find_or_load("Ns", "Klass", :hostclass).should == "foo"
129
+ end
130
+
131
+ it "should return nil if the name isn't found" do
132
+ @code.stubs(:load_until).returns(nil)
133
+ @code.find_or_load("Ns", "Klass", :hostclass).should be_nil
134
+ end
135
+ end
136
+ end
137
+
138
+ %w{hostclass node definition}.each do |data|
139
+ before do
140
+ @instance = Puppet::Resource::Type.new(data, "foo")
141
+ end
142
+
143
+ it "should have a method for adding a #{data}" do
144
+ Puppet::Resource::TypeCollection.new("env").should respond_to("add_#{data}")
145
+ end
146
+
147
+ it "should use the name of the instance to add it" do
148
+ loader = Puppet::Resource::TypeCollection.new("env")
149
+ loader.send("add_#{data}", @instance)
150
+ loader.send(data, @instance.name).should equal(@instance)
151
+ end
152
+
153
+ unless data == "hostclass"
154
+ it "should fail to add a #{data} when one already exists" do
155
+ loader = Puppet::Resource::TypeCollection.new("env")
156
+ loader.add @instance
157
+ lambda { loader.add(@instance) }.should raise_error(Puppet::ParseError)
158
+ end
159
+ end
160
+
161
+ it "should return the added #{data}" do
162
+ loader = Puppet::Resource::TypeCollection.new("env")
163
+
164
+ loader.add(@instance).should equal(@instance)
165
+ end
166
+
167
+ it "should be able to retrieve #{data} by name" do
168
+ loader = Puppet::Resource::TypeCollection.new("env")
169
+ instance = Puppet::Resource::Type.new(data, "bar")
170
+ loader.add instance
171
+ loader.send(data, "bar").should equal(instance)
172
+ end
173
+
174
+ it "should retrieve #{data} insensitive to case" do
175
+ loader = Puppet::Resource::TypeCollection.new("env")
176
+ instance = Puppet::Resource::Type.new(data, "Bar")
177
+ loader.add instance
178
+ loader.send(data, "bAr").should equal(instance)
179
+ end
180
+
181
+ it "should return nil when asked for a #{data} that has not been added" do
182
+ Puppet::Resource::TypeCollection.new("env").send(data, "foo").should be_nil
183
+ end
184
+
185
+ it "should be able to retrieve all #{data}s" do
186
+ plurals = { "hostclass" => "hostclasses", "node" => "nodes", "definition" => "definitions" }
187
+ loader = Puppet::Resource::TypeCollection.new("env")
188
+ instance = Puppet::Resource::Type.new(data, "foo")
189
+ loader.add instance
190
+ loader.send(plurals[data]).should == { "foo" => instance }
191
+ end
192
+ end
193
+
194
+ describe "when finding a qualified instance" do
195
+ it "should return any found instance if the instance name is fully qualified" do
196
+ loader = Puppet::Resource::TypeCollection.new("env")
197
+ instance = Puppet::Resource::Type.new(:hostclass, "foo::bar")
198
+ loader.add instance
199
+ loader.find("namespace", "::foo::bar", :hostclass).should equal(instance)
200
+ end
201
+
202
+ it "should return nil if the instance name is fully qualified and no such instance exists" do
203
+ loader = Puppet::Resource::TypeCollection.new("env")
204
+ loader.find("namespace", "::foo::bar", :hostclass).should be_nil
205
+ end
206
+
207
+ it "should be able to find classes in the base namespace" do
208
+ loader = Puppet::Resource::TypeCollection.new("env")
209
+ instance = Puppet::Resource::Type.new(:hostclass, "foo")
210
+ loader.add instance
211
+ loader.find("", "foo", :hostclass).should equal(instance)
212
+ end
213
+
214
+ it "should return the partially qualified object if it exists in a provided namespace" do
215
+ loader = Puppet::Resource::TypeCollection.new("env")
216
+ instance = Puppet::Resource::Type.new(:hostclass, "foo::bar::baz")
217
+ loader.add instance
218
+ loader.find("foo", "bar::baz", :hostclass).should equal(instance)
219
+ end
220
+
221
+ it "should be able to find partially qualified objects in any of the provided namespaces" do
222
+ loader = Puppet::Resource::TypeCollection.new("env")
223
+ instance = Puppet::Resource::Type.new(:hostclass, "foo::bar::baz")
224
+ loader.add instance
225
+ loader.find(["nons", "foo", "otherns"], "bar::baz", :hostclass).should equal(instance)
226
+ end
227
+
228
+ it "should return the unqualified object if it exists in a provided namespace" do
229
+ loader = Puppet::Resource::TypeCollection.new("env")
230
+ instance = Puppet::Resource::Type.new(:hostclass, "foo::bar")
231
+ loader.add instance
232
+ loader.find("foo", "bar", :hostclass).should equal(instance)
233
+ end
234
+
235
+ it "should return the unqualified object if it exists in the parent namespace" do
236
+ loader = Puppet::Resource::TypeCollection.new("env")
237
+ instance = Puppet::Resource::Type.new(:hostclass, "foo::bar")
238
+ loader.add instance
239
+ loader.find("foo::bar::baz", "bar", :hostclass).should equal(instance)
240
+ end
241
+
242
+ it "should should return the partially qualified object if it exists in the parent namespace" do
243
+ loader = Puppet::Resource::TypeCollection.new("env")
244
+ instance = Puppet::Resource::Type.new(:hostclass, "foo::bar::baz")
245
+ loader.add instance
246
+ loader.find("foo::bar", "bar::baz", :hostclass).should equal(instance)
247
+ end
248
+
249
+ it "should return the qualified object if it exists in the root namespace" do
250
+ loader = Puppet::Resource::TypeCollection.new("env")
251
+ instance = Puppet::Resource::Type.new(:hostclass, "foo::bar::baz")
252
+ loader.add instance
253
+ loader.find("foo::bar", "foo::bar::baz", :hostclass).should equal(instance)
254
+ end
255
+
256
+ it "should return nil if the object cannot be found" do
257
+ loader = Puppet::Resource::TypeCollection.new("env")
258
+ instance = Puppet::Resource::Type.new(:hostclass, "foo::bar::baz")
259
+ loader.add instance
260
+ loader.find("foo::bar", "eh", :hostclass).should be_nil
261
+ end
262
+
263
+ describe "when topscope has a class that has the same name as a local class" do
264
+ before do
265
+ @loader = Puppet::Resource::TypeCollection.new("env")
266
+ [ "foo::bar", "bar" ].each do |name|
267
+ @loader.add Puppet::Resource::Type.new(:hostclass, name)
268
+ end
269
+ end
270
+
271
+ it "should favor the local class, if the name is unqualified" do
272
+ @loader.find("foo", "bar", :hostclass).name.should == 'foo::bar'
273
+ end
274
+
275
+ it "should only look in the topclass, if the name is qualified" do
276
+ @loader.find("foo", "::bar", :hostclass).name.should == 'bar'
277
+ end
278
+
279
+ end
280
+
281
+ it "should not look in the local scope for classes when the name is qualified" do
282
+ @loader = Puppet::Resource::TypeCollection.new("env")
283
+ @loader.add Puppet::Resource::Type.new(:hostclass, "foo::bar")
284
+
285
+ @loader.find("foo", "::bar", :hostclass).should == nil
286
+ end
287
+
288
+ end
289
+
290
+ it "should use the generic 'find' method with an empty namespace to find nodes" do
291
+ loader = Puppet::Resource::TypeCollection.new("env")
292
+ loader.expects(:find).with("", "bar", :node)
293
+ loader.find_node(stub("ignored"), "bar")
294
+ end
295
+
296
+ it "should use the 'find_or_load' method to find hostclasses" do
297
+ loader = Puppet::Resource::TypeCollection.new("env")
298
+ loader.expects(:find_or_load).with("foo", "bar", :hostclass)
299
+ loader.find_hostclass("foo", "bar")
300
+ end
301
+
302
+ it "should use the 'find_or_load' method to find definitions" do
303
+ loader = Puppet::Resource::TypeCollection.new("env")
304
+ loader.expects(:find_or_load).with("foo", "bar", :definition)
305
+ loader.find_definition("foo", "bar")
306
+ end
307
+
308
+ it "should indicate whether any nodes are defined" do
309
+ loader = Puppet::Resource::TypeCollection.new("env")
310
+ loader.add_node(Puppet::Resource::Type.new(:node, "foo"))
311
+ loader.should be_nodes
312
+ end
313
+
314
+ it "should indicate whether no nodes are defined" do
315
+ Puppet::Resource::TypeCollection.new("env").should_not be_nodes
316
+ end
317
+
318
+ describe "when finding nodes" do
319
+ before :each do
320
+ @loader = Puppet::Resource::TypeCollection.new("env")
321
+ end
322
+
323
+ it "should return any node whose name exactly matches the provided node name" do
324
+ node = Puppet::Resource::Type.new(:node, "foo")
325
+ @loader << node
326
+
327
+ @loader.node("foo").should equal(node)
328
+ end
329
+
330
+ it "should return the first regex node whose regex matches the provided node name" do
331
+ node1 = Puppet::Resource::Type.new(:node, /\w/)
332
+ node2 = Puppet::Resource::Type.new(:node, /\d/)
333
+ @loader << node1 << node2
334
+
335
+ @loader.node("foo10").should equal(node1)
336
+ end
337
+
338
+ it "should preferentially return a node whose name is string-equal over returning a node whose regex matches a provided name" do
339
+ node1 = Puppet::Resource::Type.new(:node, /\w/)
340
+ node2 = Puppet::Resource::Type.new(:node, "foo")
341
+ @loader << node1 << node2
342
+
343
+ @loader.node("foo").should equal(node2)
344
+ end
345
+ end
346
+
347
+ describe "when managing files" do
348
+ before do
349
+ @loader = Puppet::Resource::TypeCollection.new("env")
350
+ Puppet::Util::LoadedFile.stubs(:new).returns stub("watched_file")
351
+ end
352
+
353
+ it "should have a method for specifying a file should be watched" do
354
+ @loader.should respond_to(:watch_file)
355
+ end
356
+
357
+ it "should have a method for determining if a file is being watched" do
358
+ @loader.watch_file("/foo/bar")
359
+ @loader.should be_watching_file("/foo/bar")
360
+ end
361
+
362
+ it "should use LoadedFile to watch files" do
363
+ Puppet::Util::LoadedFile.expects(:new).with("/foo/bar").returns stub("watched_file")
364
+ @loader.watch_file("/foo/bar")
365
+ end
366
+
367
+ it "should be considered stale if any files have changed" do
368
+ file1 = stub 'file1', :changed? => false
369
+ file2 = stub 'file2', :changed? => true
370
+ Puppet::Util::LoadedFile.expects(:new).times(2).returns(file1).then.returns(file2)
371
+ @loader.watch_file("/foo/bar")
372
+ @loader.watch_file("/other/bar")
373
+
374
+ @loader.should be_stale
375
+ end
376
+
377
+ it "should not be considered stable if no files have changed" do
378
+ file1 = stub 'file1', :changed? => false
379
+ file2 = stub 'file2', :changed? => false
380
+ Puppet::Util::LoadedFile.expects(:new).times(2).returns(file1).then.returns(file2)
381
+ @loader.watch_file("/foo/bar")
382
+ @loader.watch_file("/other/bar")
383
+
384
+ @loader.should_not be_stale
385
+ end
386
+ end
387
+
388
+ describe "when performing initial import" do
389
+ before do
390
+ @parser = Puppet::Parser::Parser.new("test")
391
+ Puppet::Parser::Parser.stubs(:new).returns @parser
392
+ @code = Puppet::Resource::TypeCollection.new("env")
393
+ end
394
+
395
+ it "should set the parser's string to the 'code' setting and parse if code is available" do
396
+ Puppet.settings[:code] = "my code"
397
+ @parser.expects(:string=).with "my code"
398
+ @parser.expects(:parse)
399
+ @code.perform_initial_import
400
+ end
401
+
402
+ it "should set the parser's file to the 'manifest' setting and parse if no code is available and the manifest is available" do
403
+ filename = tmpfile('myfile')
404
+ File.open(filename, 'w'){|f| }
405
+ Puppet.settings[:manifest] = filename
406
+ @parser.expects(:file=).with filename
407
+ @parser.expects(:parse)
408
+ @code.perform_initial_import
409
+ end
410
+
411
+ it "should pass the manifest file to the parser even if it does not exist on disk" do
412
+ filename = tmpfile('myfile')
413
+ Puppet.settings[:code] = ""
414
+ Puppet.settings[:manifest] = filename
415
+ @parser.expects(:file=).with(filename).once
416
+ @parser.expects(:parse).once
417
+ @code.perform_initial_import
418
+ end
419
+
420
+ it "should fail helpfully if there is an error importing" do
421
+ File.stubs(:exist?).returns true
422
+ @parser.expects(:parse).raises ArgumentError
423
+ @parser.stubs(:file=)
424
+ lambda { @code.perform_initial_import }.should raise_error(Puppet::Error)
425
+ end
426
+
427
+ it "should mark the type collection as needing a reparse when there is an error parsing" do
428
+ @parser.expects(:parse).raises Puppet::ParseError.new("Syntax error at ...")
429
+
430
+ lambda { @code.perform_initial_import }.should raise_error(Puppet::Error, /Syntax error at .../)
431
+ @code.require_reparse?.should be_true
432
+ end
433
+ end
434
+
435
+ describe "when determining the configuration version" do
436
+ before do
437
+ @code = Puppet::Resource::TypeCollection.new("env")
438
+ end
439
+
440
+ it "should default to the current time" do
441
+ time = Time.now
442
+
443
+ Time.stubs(:now).returns time
444
+ @code.version.should == time.to_i
445
+ end
446
+
447
+ it "should use the output of the environment's config_version setting if one is provided" do
448
+ @code.environment.stubs(:[]).with(:config_version).returns("/my/foo")
449
+
450
+ Puppet::Util.expects(:execute).with(["/my/foo"]).returns "output\n"
451
+ @code.version.should == "output"
452
+ end
453
+
454
+ it "should raise a puppet parser error if executing config_version fails" do
455
+ @code.environment.stubs(:[]).with(:config_version).returns("test")
456
+ Puppet::Util.expects(:execute).raises(Puppet::ExecutionFailure.new("msg"))
457
+
458
+ lambda { @code.version }.should raise_error(Puppet::ParseError)
459
+ end
460
+
461
+ end
462
+
463
+ end