diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-01 14:38:31 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-04-05 22:35:53 -0700 |
commit | b74d7a53addf42a2be56b262cb1207ffedf48f78 (patch) | |
tree | fc513eaa3b4988ca38892e98e752d9aef2726965 /spec | |
parent | 0537474a7c576011b12149725f65da617b3e1ef0 (diff) | |
download | chef-b74d7a53addf42a2be56b262cb1207ffedf48f78.tar.gz |
CHEF-13: remove magic from the logger/formatter settings
closes #2514
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/integration/client/client_spec.rb | 5 | ||||
-rw-r--r-- | spec/unit/application_spec.rb | 53 | ||||
-rw-r--r-- | spec/unit/client_spec.rb | 50 |
3 files changed, 50 insertions, 58 deletions
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index 1cd74a6fd1..733503de42 100644 --- a/spec/integration/client/client_spec.rb +++ b/spec/integration/client/client_spec.rb @@ -294,10 +294,9 @@ chef_server_url 'http://omg.com/blah' cookbook_path "#{path_to('cookbooks')}" EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -r 'x::default' -z", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -r 'x::default' -z -l info", :cwd => chef_dir) expect(result.stdout).not_to include("Overridden Run List") expect(result.stdout).to include("Run List is [recipe[x::default]]") - #puts result.stdout result.error! end @@ -445,7 +444,7 @@ control_group "control group without top level control" do end RECIPE - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'audit_test::succeed'", :cwd => chef_dir) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'audit_test::succeed' -l info", :cwd => chef_dir) expect(result.error?).to be_falsey expect(result.stdout).to include("Successfully executed all `control_group` blocks and contained examples") end diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index a12935fa78..72921c90ca 100644 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -1,7 +1,7 @@ # # Author:: AJ Christensen (<aj@junglist.gen.nz>) # Author:: Mark Mzyk (mmzyk@chef.io) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -192,48 +192,49 @@ describe Chef::Application do end shared_examples_for "log_level_is_auto" do - context "when STDOUT is to a tty" do + before do + allow(STDOUT).to receive(:tty?).and_return(true) + end + + it "configures the log level to :warn" do + @app.configure_logging + expect(Chef::Log.level).to eq(:warn) + end + + context "when force_formater is configured" do before do - allow(STDOUT).to receive(:tty?).and_return(true) + Chef::Config[:force_formatter] = true end - it "configures the log level to :warn" do + it "configures the log level to warn" do @app.configure_logging expect(Chef::Log.level).to eq(:warn) end - - context "when force_logger is configured" do - before do - Chef::Config[:force_logger] = true - end - - it "configures the log level to info" do - @app.configure_logging - expect(Chef::Log.level).to eq(:info) - end - end end - context "when STDOUT is not to a tty" do + context "when force_logger is configured" do before do - allow(STDOUT).to receive(:tty?).and_return(false) + Chef::Config[:force_logger] = true end - it "configures the log level to :info" do + it "configures the log level to info" do @app.configure_logging expect(Chef::Log.level).to eq(:info) end + end - context "when force_formatter is configured" do - before do - Chef::Config[:force_formatter] = true - end - it "sets the log level to :warn" do - @app.configure_logging - expect(Chef::Log.level).to eq(:warn) - end + context "when both are is configured" do + before do + Chef::Config[:force_logger] = true + Chef::Config[:force_formatter] = true + end + + it "configures the log level to warn" do + @app.configure_logging + expect(Chef::Log.level).to eq(:warn) end end + end context "when log_level is not set" do diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index 7ffc17c4fc..a2bb573e15 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -2,7 +2,7 @@ # Author:: Adam Jacob (<adam@chef.io>) # Author:: Tim Hinderliter (<tim@chef.io>) # Author:: Christopher Walters (<cw@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -71,48 +71,40 @@ describe Chef::Client do describe "configuring output formatters" do context "when no formatter has been configured" do - context "and STDOUT is a TTY" do + it "configures the :doc formatter" do + expect(client.formatters_for_run).to eq([[:doc]]) + end + + context "and force_logger is set" do before do - allow(STDOUT).to receive(:tty?).and_return(true) + Chef::Config[:force_logger] = true end - it "configures the :doc formatter" do - expect(client.formatters_for_run).to eq([[:doc]]) + it "configures the :null formatter" do + expect(client.formatters_for_run).to eq([[:null]]) end + end - context "and force_logger is set" do - before do - Chef::Config[:force_logger] = true - end - - it "configures the :null formatter" do - expect(Chef::Config[:force_logger]).to be_truthy - expect(client.formatters_for_run).to eq([[:null]]) - end - + context "and force_formatter is set" do + before do + Chef::Config[:force_formatter] = true end + it "configures the :doc formatter" do + expect(client.formatters_for_run).to eq([[:doc]]) + end end - context "and STDOUT is not a TTY" do + context "both are set" do before do - allow(STDOUT).to receive(:tty?).and_return(false) - end - - it "configures the :null formatter" do - expect(client.formatters_for_run).to eq([[:null]]) + Chef::Config[:force_formatter] = true + Chef::Config[:force_logger] = true end - context "and force_formatter is set" do - before do - Chef::Config[:force_formatter] = true - end - it "it configures the :doc formatter" do - expect(client.formatters_for_run).to eq([[:doc]]) - end + it "configures the :doc formatter" do + expect(client.formatters_for_run).to eq([[:doc]]) end end - end context "when a formatter is configured" do |