diff options
| author | Nick Lewis <nick@puppetlabs.com> | 2010-07-06 12:06:39 -0700 |
|---|---|---|
| committer | Nick Lewis <nick@puppetlabs.com> | 2010-07-07 11:51:15 -0700 |
| commit | e419293e58addfd8e4f0612ad121f68038daa14a (patch) | |
| tree | b8ab8047c6d5ca3749219cd02085c6d0372a0b39 /spec | |
| parent | 4b00c6af911b447265fc3e7ab19bb076840bfef1 (diff) | |
[#4114] Added queueing to the log
The log will now queue any log messages created when there is no
destination, and will flush the queue when a destination is added.
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/util/log_spec.rb | 19 | ||||
| -rwxr-xr-x | spec/unit/util/logging_spec.rb | 6 |
2 files changed, 24 insertions, 1 deletions
diff --git a/spec/unit/util/log_spec.rb b/spec/unit/util/log_spec.rb index 7aaa580c5..df3c36ff2 100755 --- a/spec/unit/util/log_spec.rb +++ b/spec/unit/util/log_spec.rb @@ -5,8 +5,19 @@ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f require 'puppet/util/log' describe Puppet::Util::Log do + it "should write a given message to the specified destination" do + Puppet::Util::Log.newdestination(:array) + Puppet::Util::Log.new(:level => :notice, :message => "foo") + message = Puppet::Util::Log.destinations[:array].messages.shift.message + message.should == "foo" + + Puppet::Util::Log.close_all + end + it "should be able to close all log destinations" do - Puppet::Util::Log.expects(:destinations).returns %w{foo bar} + destinations = stub_everything('destinations') + destinations.stubs(:keys).returns %w{foo bar} + Puppet::Util::Log.expects(:destinations).returns(destinations) Puppet::Util::Log.expects(:close).with("foo") Puppet::Util::Log.expects(:close).with("bar") @@ -84,6 +95,12 @@ describe Puppet::Util::Log do Puppet::Util::Log.new(:level => :notice, :message => :foo).message.should == "foo" end + it "should flush the log queue when the first destination is specified" do + Puppet::Util::Log.expects(:flushqueue) + Puppet::Util::Log.newdestination(:array) + Puppet::Util::Log.close_all + end + it "should convert the level to a symbol if it's passed in as a string" do Puppet::Util::Log.new(:level => "notice", :message => :foo).level.should == :notice end diff --git a/spec/unit/util/logging_spec.rb b/spec/unit/util/logging_spec.rb index aee308eca..41b07d433 100755 --- a/spec/unit/util/logging_spec.rb +++ b/spec/unit/util/logging_spec.rb @@ -40,6 +40,12 @@ describe Puppet::Util::Logging do @logger.notice "foo" end + it "should queue logs sent without a specified destination" do + Puppet::Util::Log.expects(:queuemessage) + + @logger.notice "foo" + end + it "should use the path of any provided resource type" do resource = Puppet::Type.type(:mount).new :name => "foo" |
