diff options
| author | Matt Robinson <matt@puppetlabs.com> | 2010-07-07 10:30:15 -0700 |
|---|---|---|
| committer | Nick Lewis <nick@puppetlabs.com> | 2010-07-07 11:51:54 -0700 |
| commit | cdd43825cee233af478d807cddda346e9d1fe142 (patch) | |
| tree | 51f56c551f8364efa3053e404f04db568fa69943 | |
| parent | e419293e58addfd8e4f0612ad121f68038daa14a (diff) | |
| download | puppet-cdd43825cee233af478d807cddda346e9d1fe142.tar.gz puppet-cdd43825cee233af478d807cddda346e9d1fe142.tar.xz puppet-cdd43825cee233af478d807cddda346e9d1fe142.zip | |
[#4114] Fix failures in the unit tests
The initial commit changed the name of a method (close -> close_all) and
changed the way the array log destination worked before we saw that the
unit tests were using it differently.
| -rw-r--r-- | lib/puppet/util/log/destinations.rb | 9 | ||||
| -rw-r--r-- | spec/spec_helper.rb | 5 | ||||
| -rwxr-xr-x | spec/unit/util/log_spec.rb | 19 | ||||
| -rwxr-xr-x | spec/unit/util/logging_spec.rb | 1 | ||||
| -rwxr-xr-x | test/lib/puppettest.rb | 2 | ||||
| -rwxr-xr-x | test/util/log.rb | 7 |
6 files changed, 16 insertions, 27 deletions
diff --git a/lib/puppet/util/log/destinations.rb b/lib/puppet/util/log/destinations.rb index 403733d35..e748e5108 100644 --- a/lib/puppet/util/log/destinations.rb +++ b/lib/puppet/util/log/destinations.rb @@ -218,17 +218,12 @@ end Puppet::Util::Log.newdesttype :array do match "Array" - attr_accessor :messages - def initialize - @messages = [] + def initialize(messages) + @messages = messages end def handle(msg) @messages << msg end - - def close - @messages.clear - end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bd5b9a1b3..e7dd55482 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -65,6 +65,8 @@ Spec::Runner.configure do |config| end $tmpfiles.clear end + + Puppet::Util::Log.close_all end config.prepend_before :each do @@ -79,6 +81,9 @@ Spec::Runner.configure do |config| # Avoid opening ports to the outside world Puppet.settings[:bindaddress] = "127.0.0.1" + + @logs = [] + Puppet::Util::Log.newdestination(@logs) end end diff --git a/spec/unit/util/log_spec.rb b/spec/unit/util/log_spec.rb index df3c36ff2..e188a2366 100755 --- a/spec/unit/util/log_spec.rb +++ b/spec/unit/util/log_spec.rb @@ -6,22 +6,11 @@ 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) + arraydest = [] + Puppet::Util::Log.newdestination(arraydest) Puppet::Util::Log.new(:level => :notice, :message => "foo") - message = Puppet::Util::Log.destinations[:array].messages.shift.message + message = arraydest.last.message message.should == "foo" - - Puppet::Util::Log.close_all - end - - it "should be able to close all log destinations" do - 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") - - Puppet::Util::Log.close_all end describe Puppet::Util::Log::DestConsole do @@ -96,9 +85,9 @@ describe Puppet::Util::Log do end it "should flush the log queue when the first destination is specified" do + Puppet::Util::Log.close_all 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 diff --git a/spec/unit/util/logging_spec.rb b/spec/unit/util/logging_spec.rb index 41b07d433..62a66fc92 100755 --- a/spec/unit/util/logging_spec.rb +++ b/spec/unit/util/logging_spec.rb @@ -41,6 +41,7 @@ describe Puppet::Util::Logging do end it "should queue logs sent without a specified destination" do + Puppet::Util::Log.close_all Puppet::Util::Log.expects(:queuemessage) @logger.notice "foo" diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb index 32f57f394..f94fb4cec 100755 --- a/test/lib/puppettest.rb +++ b/test/lib/puppettest.rb @@ -319,7 +319,7 @@ module PuppetTest end # reset all of the logs - Puppet::Util::Log.close + Puppet::Util::Log.close_all @logs.clear # Just in case there are processes waiting to die... diff --git a/test/util/log.rb b/test/util/log.rb index 00db10e61..b28d601e9 100755 --- a/test/util/log.rb +++ b/test/util/log.rb @@ -12,14 +12,13 @@ class TestLog < Test::Unit::TestCase def setup super @oldloglevel = Puppet::Util::Log.level - Puppet::Util::Log.close + Puppet::Util::Log.close_all end def teardown super - Puppet::Util::Log.close + Puppet::Util::Log.close_all Puppet::Util::Log.level = @oldloglevel - Puppet::Util::Log.newdestination(:console) end def getlevels @@ -57,7 +56,7 @@ class TestLog < Test::Unit::TestCase } msgs = mkmsgs(levels) assert(msgs.length == levels.length) - Puppet::Util::Log.close + Puppet::Util::Log.close_all count = 0 assert(FileTest.exists?(logfile), "Did not create logfile") |
