From dfcee63afb19d72677f177e83ce237765cccf0f7 Mon Sep 17 00:00:00 2001 From: Peter Meier Date: Wed, 23 May 2012 21:42:07 +0200 Subject: (#14670) autorequire a file_line resource's path If we manage a file we edit with file_line, it should be autorequired by file_line. Without this patch applied the relationship is not automatically setup and the user is forced to manually manage the relationship. --- spec/unit/puppet/type/file_line_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'spec') diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index e1c07ac..1fa8e84 100644 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -48,4 +48,23 @@ describe Puppet::Type.type(:file_line) do it 'should default to ensure => present' do file_line[:ensure].should eq :present end + + it "should autorequire the file it manages" do + catalog = Puppet::Resource::Catalog.new + file = Puppet::Type.type(:file).new(:name => "/tmp/path") + catalog.add_resource file + catalog.add_resource file_line + reqs = file_line.autorequire + reqs.size.should eq 1 + reqs[0].source.should eq file + reqs[0].target.should eq file_line + end + + it "should not autorequire the file it manages if it is not managed" do + catalog = Puppet::Resource::Catalog.new + catalog.add_resource file_line + reqs = file_line.autorequire + reqs.size.should eq 0 + end + end -- cgit v1.2.3 From d8cde952956e80eeae617469c59a3bbd61336e70 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Mon, 26 Nov 2012 11:37:08 -0800 Subject: (#14670) Fixup file_line autorequire specs Without this patch applied the file_line autorequire examples are failing. This is a problem because the failures are false positives and should be passing given the implementation. This patch fixes the problem by changing the examples to directly test the existence of the relationship by finding it in the list of autorequire relationships. --- spec/unit/puppet/type/file_line_spec.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'spec') diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index 1fa8e84..0cd8a26 100644 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -54,17 +54,16 @@ describe Puppet::Type.type(:file_line) do file = Puppet::Type.type(:file).new(:name => "/tmp/path") catalog.add_resource file catalog.add_resource file_line - reqs = file_line.autorequire - reqs.size.should eq 1 - reqs[0].source.should eq file - reqs[0].target.should eq file_line + + relationship = file_line.autorequire.find do |rel| + (rel.source.to_s == "File[/tmp/path]") and (rel.target.to_s == file_line.to_s) + end + relationship.should be_a Puppet::Relationship end it "should not autorequire the file it manages if it is not managed" do catalog = Puppet::Resource::Catalog.new catalog.add_resource file_line - reqs = file_line.autorequire - reqs.size.should eq 0 + file_line.autorequire.should be_empty end - end -- cgit v1.2.3