diff options
author | Marc A. Paradise <marc.paradise@gmail.com> | 2019-04-29 22:30:05 -0400 |
---|---|---|
committer | Marc A. Paradise <marc.paradise@gmail.com> | 2019-05-01 08:17:21 -0400 |
commit | d822cab9f00521af523c46b87d2f5c7b97e77523 (patch) | |
tree | d748058f2a5b773037d1956932514ac3063bfef4 /spec | |
parent | 024e3c261da7159562e9c3712fb1b533297c7610 (diff) | |
download | chef-d822cab9f00521af523c46b87d2f5c7b97e77523.tar.gz |
Fix incorrect deprecation warningsmp/bootstrap-deprecation-fixes
Fixed incorrect option mapping where deprecated flags
would have a 'long' taken from the replacement flag.
Updated the behavior in case of conflicting flags
(for example --ssh-user and --connection-user) to avoid
surprising results by failing with an error instead
of trying to resolve intent.
Renamed things a bit for readability/consistency.
Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index ce590fc9ee..5bef9c5659 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -1571,7 +1571,7 @@ describe Chef::Knife::Bootstrap do end it "performs the steps we expect to run a bootstrap" do - expect(knife).to receive(:warn_and_map_deprecated_flags).ordered + expect(knife).to receive(:verify_deprecated_flags!).ordered expect(knife).to receive(:validate_name_args!).ordered expect(knife).to receive(:validate_protocol!).ordered expect(knife).to receive(:validate_first_boot_attributes!).ordered @@ -1593,7 +1593,7 @@ describe Chef::Knife::Bootstrap do end end - describe "#warn_and_map_deprecated_flags" do + describe "#verify_deprecated_flags!" do before do Chef::Config[:silence_deprecation_warnings] = false end @@ -1605,7 +1605,7 @@ describe Chef::Knife::Bootstrap do end it "maps the key value to the new key and points the human to the new flag" do expect(knife.ui).to receive(:warn).with(/--ssh-user USER is deprecated. Use --connection-user USERNAME instead./) - knife.warn_and_map_deprecated_flags + knife.verify_deprecated_flags! expect(knife.config[:connection_user]).to eq "sshuser" end end @@ -1616,10 +1616,10 @@ describe Chef::Knife::Bootstrap do knife.config[:connection_user] = "real-user" knife.merge_configs end - it "warns that both are provided and takes the non-deprecated value" do - expect(knife.ui).to receive(:warn).with(/You provided both --connection-user and --ssh-user.*'--connection-user real-user'/m) - knife.warn_and_map_deprecated_flags - expect(knife.config[:connection_user]).to eq "real-user" + + it "informs the human that both are provided and exits" do + expect(knife.ui).to receive(:error).with(/You provided both --connection-user and --ssh-user.*Please use.*/m) + expect { knife.verify_deprecated_flags! }.to raise_error SystemExit end end end |