diff options
author | Nikhil Benesch <nikhil.benesch@gmail.com> | 2014-01-13 00:00:31 -0500 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2014-01-20 16:58:41 -0800 |
commit | 6a4b9a7849f4c60fdd2b016b288e01f2a6fd03f2 (patch) | |
tree | 3bab09fd5bd64cfc24f0f3573dbe54fef2f41bc5 /spec/unit/application_spec.rb | |
parent | e15f04b1ed124767a04ef4f5de4f8678fcbe33df (diff) | |
download | chef-6a4b9a7849f4c60fdd2b016b288e01f2a6fd03f2.tar.gz |
CHEF-4725: Validate 'log_location' setting on log initialization
Previously, a Mixlib::Config setter method verified that 'log_location'
was set to a writeable file or a valid IO stream. Due to the way
Mixlib::Config handles `default` and `merge!`, this setter method would
not fire if the 'log_location' was left unconfigured or if it was set
on the command line, resulting in inconsistent error handling.
This commit moves the validation logic out of the configuration layer
and into the log initializion layer. This ensures that error handling is
consistent, regardless of where the 'log_location' setting is
configured. Validation logic is also simplified, relying on the
MonoLogger class to open and configure any necessary IO streams.
Diffstat (limited to 'spec/unit/application_spec.rb')
-rw-r--r-- | spec/unit/application_spec.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index 1606c82531..426dbd5242 100644 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -163,6 +163,13 @@ describe Chef::Application do @app.configure_logging end + it "should raise fatals if log location is invalid" do + Chef::Config[:log_location] = "/tmp/non-existing-dir/logfile" + Chef::Log.should_receive(:fatal).at_least(:once) + Process.should_receive(:exit) + @app.configure_logging + end + shared_examples_for "log_level_is_auto" do context "when STDOUT is to a tty" do before do @@ -306,11 +313,6 @@ describe Chef::Application do @config_file.unlink end - it "should raise informative fatals for missing log file dir" do - create_config_file('log_location "/tmp/non-existing-dir/logfile"') - raises_informative_fatals_on_configure_chef - end - it "should raise informative fatals for badly written config" do create_config_file("text that should break the config parsing") raises_informative_fatals_on_configure_chef |