diff options
| author | Luke Kanies <luke@madstop.com> | 2009-11-07 17:46:19 -0600 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | e838bccaee658847e1b2dac5b7e2191a8148202c (patch) | |
| tree | 2fcaa850dc2e0613a95201574daad24cc83f48bf /spec/unit | |
| parent | 977595bd712bfa25c176abb3983bc81df665ea7b (diff) | |
Solidifying the RAL/Event integration.
This has two changes:
* Clarifies how we get the property and resource
name (we pass the instance, the event converts to a
string)
* Logs at the resource's loglevel when there's no error
These are related, because the event creator (resource) was
passing in a string rather than an instance.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x | spec/unit/parameter.rb | 4 | ||||
| -rwxr-xr-x | spec/unit/property.rb | 6 | ||||
| -rwxr-xr-x | spec/unit/transaction/event.rb | 9 | ||||
| -rwxr-xr-x | spec/unit/type.rb | 5 |
4 files changed, 22 insertions, 2 deletions
diff --git a/spec/unit/parameter.rb b/spec/unit/parameter.rb index f4473248a..03674cb88 100755 --- a/spec/unit/parameter.rb +++ b/spec/unit/parameter.rb @@ -22,6 +22,10 @@ describe Puppet::Parameter do @class.value_collection.should be_instance_of(Puppet::Parameter::ValueCollection) end + it "should return its name as a string when converted to a string" do + @parameter.to_s.should == @parameter.name.to_s + end + it "should be able to use cached attributes" do Puppet::Parameter.ancestors.should be_include(Puppet::Util::Cacher) end diff --git a/spec/unit/property.rb b/spec/unit/property.rb index eba5c3d83..af3dbc408 100755 --- a/spec/unit/property.rb +++ b/spec/unit/property.rb @@ -15,6 +15,10 @@ describe Puppet::Property do @property = @class.new :resource => @resource end + it "should return its name as a string when converted to a string" do + @property.to_s.should == @property.name.to_s + end + it "should be able to look up the modified name for a given value" do @class.newvalue(:foo) @class.value_name("foo").should == :foo @@ -129,7 +133,7 @@ describe Puppet::Property do end it "should have the property's name" do - @instance.event.property.should == @instance.name + @instance.event.property.should == @instance.name.to_s end it "should have the 'should' value set" do diff --git a/spec/unit/transaction/event.rb b/spec/unit/transaction/event.rb index 07470b2b9..6a837b50f 100755 --- a/spec/unit/transaction/event.rb +++ b/spec/unit/transaction/event.rb @@ -51,7 +51,14 @@ describe Puppet::Transaction::Event do Puppet::Util::Log.stubs(:new) end - it "should set the level to 'notice' if the event status is 'success'" do + it "should set the level to the resources's log level if the event status is 'success' and a resource is available" do + resource = stub 'resource' + resource.expects(:[]).with(:loglevel).returns :myloglevel + Puppet::Util::Log.expects(:create).with { |args| args[:level] == :myloglevel } + Puppet::Transaction::Event.new(:status => "success", :resource => resource).send_log + end + + it "should set the level to 'notice' if the event status is 'success' and no resource is available" do Puppet::Util::Log.expects(:new).with { |args| args[:level] == :notice } Puppet::Transaction::Event.new(:status => "success").send_log end diff --git a/spec/unit/type.rb b/spec/unit/type.rb index be456a88b..9e6469c0f 100755 --- a/spec/unit/type.rb +++ b/spec/unit/type.rb @@ -111,6 +111,11 @@ describe Puppet::Type do @resource.event.resource.should == "Mount[foo]" end + it "should have the resource's log level as the default log level" do + @resource[:loglevel] = :warning + @resource.event.default_log_level.should == :warning + end + {:file => "/my/file", :line => 50, :tags => %{foo bar}, :version => 50}.each do |attr, value| it "should set the #{attr}" do @resource.stubs(attr).returns value |
