diff options
author | sawanoboly <sawanoboriyu@higanworks.com> | 2015-04-26 01:55:18 +0900 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-05-06 15:09:44 -0700 |
commit | a9d79036e58968da8554d3ffb563865e104e96f8 (patch) | |
tree | 47d202c4ddb2cd7c944dd3a0c87f8b6f867bb0bc | |
parent | 113c7cf873049dfc2387d5276ad11f16a1427f2a (diff) | |
download | chef-a9d79036e58968da8554d3ffb563865e104e96f8.tar.gz |
move syslog specs to functional and call Chef::Log methods.
-rw-r--r-- | spec/functional/log/syslog_spec.rb | 46 | ||||
-rw-r--r-- | spec/unit/log_spec.rb | 21 |
2 files changed, 46 insertions, 21 deletions
diff --git a/spec/functional/log/syslog_spec.rb b/spec/functional/log/syslog_spec.rb new file mode 100644 index 0000000000..9fdfa917fd --- /dev/null +++ b/spec/functional/log/syslog_spec.rb @@ -0,0 +1,46 @@ +# +# Author:: SAWANOBORI Yukihiko (<sawanoboriyu@higanworks.com>) +# Copyright:: Copyright (c) 2015 Opscode, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'spec_helper' +require 'chef' + +describe Chef::Log::Syslog, :unix_only => true do + let(:syslog) { Chef::Log::Syslog.new } + let(:app) { Chef::Application.new } + + before do + Chef::Config[:log_level] = :info + Chef::Config[:log_location] = syslog + app.configure_logging + end + + it "should send message with severity info to syslog." do + expect_any_instance_of(Logger::Syslog).to receive(:info).with("*** Chef 12.4.0.dev.0 ***") + Chef::Log.info("*** Chef 12.4.0.dev.0 ***") + end + + it "should send message with severity warning to syslog." do + expect_any_instance_of(Logger::Syslog).to receive(:warn).with("No config file found or specified on command line, using command line options.") + Chef::Log.warn("No config file found or specified on command line, using command line options.") + end + + it "should fallback into send message with severity info to syslog when wrong format." do + expect_any_instance_of(Logger::Syslog).to receive(:info).with("chef message") + syslog.write("chef message") + end +end diff --git a/spec/unit/log_spec.rb b/spec/unit/log_spec.rb index 84627494be..7be40f77e6 100644 --- a/spec/unit/log_spec.rb +++ b/spec/unit/log_spec.rb @@ -22,24 +22,3 @@ require 'spec_helper' describe Chef::Log do end - -unless Chef::Platform.windows? - describe Chef::Log::Syslog do - let(:logger) { Chef::Log::Syslog.new } - - it "should send message with severity info to syslog." do - expect_any_instance_of(Logger::Syslog).to receive(:info).with("*** Chef 12.4.0.dev.0 ***") - logger.write("[2015-04-23T15:16:23+09:00] INFO: *** Chef 12.4.0.dev.0 ***") - end - - it "should send message with severity warning to syslog." do - expect_any_instance_of(Logger::Syslog).to receive(:warn).with("No config file found or specified on command line, using command line options.") - logger.write("[2015-04-23T15:16:20+09:00] WARN: No config file found or specified on command line, using command line options.") - end - - it "should fallback into send message with severity info to syslog when wrong format." do - expect_any_instance_of(Logger::Syslog).to receive(:info).with("chef message") - logger.write("chef message") - end - end -end |