summaryrefslogtreecommitdiff
path: root/spec/unit/knife_spec.rb
diff options
context:
space:
mode:
authorMarc A. Paradise <marc.paradise@gmail.com>2019-05-01 10:22:24 -0400
committerMarc A. Paradise <marc.paradise@gmail.com>2019-05-03 17:30:08 -0400
commit3e3d4b1ac9c2aefd12eae60982eb321c1029ab44 (patch)
tree3a39230b475b007837d41f2f31c203cef6287e98 /spec/unit/knife_spec.rb
parentba50ae6d20ef86ab39b9fa2eee982f929cd70c7e (diff)
downloadchef-3e3d4b1ac9c2aefd12eae60982eb321c1029ab44.tar.gz
Make config_source aware of cli defaults
If a value comes from CLI defaults, it will now return :cli_default. This supports verifying deprecations when we need to know if a value was actually supplied from the CLI, or if it was defaulted from CLI options. Since we have all of the original sources still available, this also makes it so that we don't keep a separate hash for tracking config source - we're just checking in the original config sources in order that matches merge priority. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Diffstat (limited to 'spec/unit/knife_spec.rb')
-rw-r--r--spec/unit/knife_spec.rb21
1 files changed, 5 insertions, 16 deletions
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index 7e05bec8f7..6fcb831531 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -299,37 +299,26 @@ describe Chef::Knife do
expect(Chef::Config[:log_level]).to eql(:warn)
end
- it "prefers the default value if no config or command line value is present and reports the source as default" do
+ it "prefers the default value from option definition if no config or command line value is present and reports the source as default" do
knife_command = KnifeSpecs::TestYourself.new([]) # empty argv
knife_command.configure_chef
expect(knife_command.config[:opt_with_default]).to eq("default-value")
+ expect(knife_command.config_source(:opt_with_default)).to eq(:cli_default)
end
- it "prefers a value in Chef::Config[:knife] to the default" do
+ it "prefers a value in Chef::Config[:knife] to the default and reports the source as config" do
Chef::Config[:knife][:opt_with_default] = "from-knife-config"
knife_command = KnifeSpecs::TestYourself.new([]) # empty argv
knife_command.configure_chef
expect(knife_command.config[:opt_with_default]).to eq("from-knife-config")
- expect(knife_command.config_source(:opt_with_default)).to eq (:config)
- end
-
- it "correctly reports Chef::Config as the source when a a config entry comes from there" do
- Chef::Config[:knife][:opt_with_default] = "from-knife-config"
- knife_command = KnifeSpecs::TestYourself.new([]) # empty argv
- knife_command.configure_chef
- expect(knife_command.config_source(:opt_with_default)).to eq (:config)
+ expect(knife_command.config_source(:opt_with_default)).to eq(:config)
end
it "prefers a value from command line over Chef::Config and the default and reports the source as CLI" do
knife_command = KnifeSpecs::TestYourself.new(["-D", "from-cli"])
knife_command.configure_chef
expect(knife_command.config[:opt_with_default]).to eq("from-cli")
- expect(knife_command.config_source(:opt_with_default)).to eq (:cli)
- end
- it "correctly reports CLI as the source when a config entry comes from the CLI" do
- knife_command = KnifeSpecs::TestYourself.new(["-D", "from-cli"])
- knife_command.configure_chef
- expect(knife_command.config_source(:opt_with_default)).to eq (:cli)
+ expect(knife_command.config_source(:opt_with_default)).to eq(:cli)
end
it "merges `listen` config to Chef::Config" do