diff options
author | Tim Smith <tsmith@chef.io> | 2019-05-10 19:24:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-10 19:24:21 -0700 |
commit | 228e8bcbf9c56b24fbcb75ae8b7a9f471537f96d (patch) | |
tree | 755ab40aa2af47e5171fd37476280d8684ce4217 /spec | |
parent | 8d14431e7eeb231e964dfa0c834667a4a4deac38 (diff) | |
parent | cb3aead33cd5aebea7162f0979989efe8a789861 (diff) | |
download | chef-228e8bcbf9c56b24fbcb75ae8b7a9f471537f96d.tar.gz |
Merge pull request #8506 from chef/KNIFE-EC2-567/handle-unmerged-case
[knife-ec2-547] Update config_source to support using knife classes without requiring merge_config
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/knife_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb index 6fcb831531..080b2ffa29 100644 --- a/spec/unit/knife_spec.rb +++ b/spec/unit/knife_spec.rb @@ -280,6 +280,31 @@ describe Chef::Knife do expect(other_deps_loaded).to be_truthy end + describe "working with unmerged configuration in #config_source" do + let(:command) { KnifeSpecs::TestYourself.new([]) } + + before do + KnifeSpecs::TestYourself.option(:opt_with_default, + short: "-D VALUE", + default: "default-value") + end + # This supports a use case used by plugins, where the pattern + # seems to follow: + # cmd = KnifeCommand.new + # cmd.config[:config_key] = value + # cmd.run + # + # This bypasses Knife::run and the `merge_configs` call it + # performs - config_source should break when that happens. + context "when config is fed in directly without a merge" do + it "retains the value but returns nil as a config source" do + command.config[:test1] = "value" + expect(command.config[:test1]).to eq "value" + expect(command.config_source(:test1)).to eq nil + end + end + + end describe "merging configuration options" do before do KnifeSpecs::TestYourself.option(:opt_with_default, |