summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2016-11-23 11:52:10 -0500
committerGitHub <noreply@github.com>2016-11-23 11:52:10 -0500
commit92041a5853cc9cc9b05c9f46f8becba4c5ba3656 (patch)
tree8510b793bb731054982b14edecfb9190f94b1c90 /spec
parentd072af9f1d64981130bf9c16339f19057f20662f (diff)
parent63a6d5e5f24e26662d520b366b8604b81b757c3a (diff)
downloadchef-92041a5853cc9cc9b05c9f46f8becba4c5ba3656.tar.gz
Merge pull request #5502 from MsysTechnologiesllc/dheeraj/configurable_log_details
Knife Bootstrap: Passing config_log_level and config_log_location from config.rb
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/knife/core/bootstrap_context_spec.rb60
1 files changed, 55 insertions, 5 deletions
diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb
index 6465e18ac9..515381cf6e 100644
--- a/spec/unit/knife/core/bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/bootstrap_context_spec.rb
@@ -30,6 +30,8 @@ describe Chef::Knife::Core::BootstrapContext do
let(:run_list) { Chef::RunList.new("recipe[tmux]", "role[base]") }
let(:chef_config) do
{
+ :config_log_level => "info",
+ :config_log_location => "/tmp/log",
:validation_key => File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem"),
:chef_server_url => "http://chef.example.com:4444",
:validation_client_name => "chef-validator-testing",
@@ -68,18 +70,15 @@ describe Chef::Knife::Core::BootstrapContext do
it "generates the config file data" do
expected = <<-EXPECTED
-log_location STDOUT
chef_server_url "http://chef.example.com:4444"
validation_client_name "chef-validator-testing"
+log_level :info
+log_location "/tmp/log"
# Using default node name (fqdn)
EXPECTED
expect(bootstrap_context.config_content).to eq expected
end
- it "does not set a default log_level" do
- expect(bootstrap_context.config_content).not_to match(/log_level/)
- end
-
describe "alternate chef-client path" do
let(:chef_config) { { :chef_client_path => "/usr/local/bin/chef-client" } }
it "runs chef-client from another path when specified" do
@@ -254,4 +253,55 @@ EXPECTED
end
end
+ describe "#config_log_location" do
+ context "when config_log_location is nil" do
+ let(:chef_config) { { :config_log_location => nil } }
+ it "sets the default config_log_location in the client.rb" do
+ expect(bootstrap_context.get_log_location).to eq "STDOUT"
+ end
+ end
+
+ context "when config_log_location is empty" do
+ let(:chef_config) { { :config_log_location => "" } }
+ it "sets the default config_log_location in the client.rb" do
+ expect(bootstrap_context.get_log_location).to eq "STDOUT"
+ end
+ end
+
+ context "when config_log_location is :win_evt" do
+ let(:chef_config) { { :config_log_location => :win_evt } }
+ it "raise error when config_log_location is :win_evt " do
+ expect { bootstrap_context.get_log_location }.to raise_error("The value :win_evt is not supported for config_log_location on Linux Platforms \n")
+ end
+ end
+
+ context "when config_log_location is :syslog" do
+ let(:chef_config) { { :config_log_location => :syslog } }
+ it "sets the config_log_location value as :syslog in the client.rb" do
+ expect(bootstrap_context.get_log_location).to eq ":syslog"
+ end
+ end
+
+ context "When config_log_location is STDOUT" do
+ let(:chef_config) { { :config_log_location => STDOUT } }
+ it "Sets the config_log_location value as STDOUT in the client.rb" do
+ expect(bootstrap_context.get_log_location).to eq "STDOUT"
+ end
+ end
+
+ context "when config_log_location is STDERR" do
+ let(:chef_config) { { :config_log_location => STDERR } }
+ it "sets the config_log_location value as STDERR in the client.rb" do
+ expect(bootstrap_context.get_log_location).to eq "STDERR"
+ end
+ end
+
+ context "when config_log_location is a path" do
+ let(:chef_config) { { :config_log_location => "/tmp/ChefLogFile" } }
+ it "sets the config_log_location path in the client.rb" do
+ expect(bootstrap_context.get_log_location).to eq "\"/tmp/ChefLogFile\""
+ end
+ end
+
+ end
end