diff options
| author | Luke Kanies <luke@madstop.com> | 2009-08-03 11:53:58 -0700 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-08-04 07:26:59 +1000 |
| commit | f6cc59803b32dd1d62cbc5e8ae16ac675ffb296d (patch) | |
| tree | 4a924f8b18c502188f07284f621ac15c90a4aeed /spec | |
| parent | 7c4c00f9e0a8120f6ee273c81cf1aff4379b83c2 (diff) | |
| download | puppet-f6cc59803b32dd1d62cbc5e8ae16ac675ffb296d.tar.gz puppet-f6cc59803b32dd1d62cbc5e8ae16ac675ffb296d.tar.xz puppet-f6cc59803b32dd1d62cbc5e8ae16ac675ffb296d.zip | |
Fixes #2483 - Log only copies metadata from RAL objects
We were previously trying to figure out what data
was available based on what methods existed, but
that caught a different method profile from
modules.
This fixes it so we only look for this data from
Puppet::Type or Puppet::Parameter instances.
I had to add the ability to skip data that's
not available, since File's 'ensure' parameter
doesn't have 'file' data, I assume because of
the metaprogramming we do around the 'file' value
for 'ensure'. It's a workaround for now, and there's
a test in there to verify it, anyway.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/util/log.rb | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/spec/unit/util/log.rb b/spec/unit/util/log.rb index 9d1b4108e..70309e456 100755 --- a/spec/unit/util/log.rb +++ b/spec/unit/util/log.rb @@ -112,7 +112,7 @@ describe Puppet::Util::Log do report.should be_include(log.time.to_s) end - describe "when setting the source" do + describe "when setting the source as a RAL object" do it "should tag itself with any tags the source has" do source = Puppet::Type.type(:file).new :path => "/foo/bar" log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => source) @@ -121,6 +121,16 @@ describe Puppet::Util::Log do end end + it "should copy over any version information" do + catalog = Puppet::Resource::Catalog.new + catalog.version = 25 + source = Puppet::Type.type(:file).new :path => "/foo/bar" + catalog.add_resource source + + log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => source) + log.version.should == 25 + end + it "should copy over any file and line information" do source = Puppet::Type.type(:file).new :path => "/foo/bar" source.file = "/my/file" @@ -130,14 +140,19 @@ describe Puppet::Util::Log do log.line.should == 50 end - it "should copy over any version information" do - catalog = Puppet::Resource::Catalog.new - catalog.version = 25 - source = Puppet::Type.type(:file).new :path => "/foo/bar" - catalog.add_resource source + it "should not fail when RAL objects don't actually support all of the metadata" do + file = Puppet::Type.type(:file).new :path => "/foo/bar", :ensure => :file + source = file.property(:ensure) + log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => source) + log.file.should be_nil + end + end + describe "when setting the source as a non-RAL object" do + it "should not try to copy over file, version, line, or tag information" do + source = Puppet::Module.new("foo") + source.expects(:file).never log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => source) - log.version.should == 25 end end end |
