File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 5050 end
5151 end
5252
53+ # Autorequire the file resource if it's being managed
54+ autorequire ( :file ) do
55+ self [ :path ]
56+ end
57+
5358 validate do
5459 unless self [ :line ] and self [ :path ]
5560 raise ( Puppet ::Error , "Both line and path are required attributes" )
Original file line number Diff line number Diff line change 4848 it 'should default to ensure => present' do
4949 file_line [ :ensure ] . should eq :present
5050 end
51+
52+ it "should autorequire the file it manages" do
53+ catalog = Puppet ::Resource ::Catalog . new
54+ file = Puppet ::Type . type ( :file ) . new ( :name => "/tmp/path" )
55+ catalog . add_resource file
56+ catalog . add_resource file_line
57+
58+ relationship = file_line . autorequire . find do |rel |
59+ ( rel . source . to_s == "File[/tmp/path]" ) and ( rel . target . to_s == file_line . to_s )
60+ end
61+ relationship . should be_a Puppet ::Relationship
62+ end
63+
64+ it "should not autorequire the file it manages if it is not managed" do
65+ catalog = Puppet ::Resource ::Catalog . new
66+ catalog . add_resource file_line
67+ file_line . autorequire . should be_empty
68+ end
5169end
You can’t perform that action at this time.
0 commit comments