diff options
author | Tim Smith <tsmith@chef.io> | 2019-08-13 12:12:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-13 12:12:39 -0700 |
commit | 5aad0f726a500a74da2e8f1a1e7855ab8c14fc68 (patch) | |
tree | 3e8aebeee784529d8671443796975686d82b5bb1 /spec | |
parent | 4605e8c06d02dae202cf55fd196b75500289f4f0 (diff) | |
parent | 938f2f1029665a33df34524a49505d03e8c427f9 (diff) | |
download | chef-5aad0f726a500a74da2e8f1a1e7855ab8c14fc68.tar.gz |
Merge pull request #8782 from MsysTechnologiesllc/VSingh/chef-14/raise-error-bootstrap-chef-15-from-chef-14
Chef-14: Raise an error on Chef 14 when trying to bootstrap Chef 15
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index 76b9d49a8c..e4e89b2db3 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -633,6 +633,92 @@ describe Chef::Knife::Bootstrap do end + describe "#validate_bootstrap_version_options!" do + describe "chef-14 or lower" do + before do + stub_const("Chef::VERSION", "14.0") + end + + context "when bootstrap version not given" do + it "passes the validation" do + knife.config[:bootstrap_version] = nil + expect { knife.validate_bootstrap_version_options! }.to_not raise_error + end + end + + context "when bootstrap version is given" do + it "passes the validation for chef 14.12.0 bootstrap version" do + knife.config[:bootstrap_version] = "14.12.0" + expect { knife.validate_bootstrap_version_options! }.to_not raise_error + end + + it "passes the validation for chef 13.12.0 bootstrap version" do + knife.config[:bootstrap_version] = "13.12.0" + expect { knife.validate_bootstrap_version_options! }.to_not raise_error + end + + it "raise an error for latest bootstrap version" do + knife.config[:bootstrap_version] = "latest" + expect { knife.validate_bootstrap_version_options! }.to raise_error(SystemExit) + end + + it "raise an error for chef 15.0+ bootstrap version" do + knife.config[:bootstrap_version] = "15.0.1" + expect { knife.validate_bootstrap_version_options! }.to raise_error(SystemExit) + end + + it "raise an error for chef 15.1+ bootstrap version" do + knife.config[:bootstrap_version] = "15.1" + expect { knife.validate_bootstrap_version_options! }.to raise_error(SystemExit) + end + end + + context "when prerelease option is given" do + it "raise an error" do + knife.config[:prerelease] = true + expect { knife.validate_bootstrap_version_options! }.to raise_error(SystemExit) + end + end + end + + describe "chef-15+" do + before do + stub_const("Chef::VERSION", "15.0") + end + + context "when bootstrap version not given" do + it "passes the validation" do + knife.config[:bootstrap_version] = nil + expect { knife.validate_bootstrap_version_options! }.to_not raise_error + end + end + + context "when bootstrap version is given" do + it "passes the validation for chef 14.12.0 bootstrap version" do + knife.config[:bootstrap_version] = "14.12.0" + expect { knife.validate_bootstrap_version_options! }.to_not raise_error + end + + it "passes the validation for chef 15.2 bootstrap version" do + knife.config[:bootstrap_version] = "15.2" + expect { knife.validate_bootstrap_version_options! }.to_not raise_error + end + + it "passes the validation for chef 16.2 bootstrap version" do + knife.config[:bootstrap_version] = "16.2" + expect { knife.validate_bootstrap_version_options! }.to_not raise_error + end + end + + context "when prerelease option is given" do + it "passes the validation" do + knife.config[:prerelease] = true + expect { knife.validate_bootstrap_version_options! }.to_not raise_error + end + end + end + end + describe "when configuring the underlying knife ssh command" do context "from the command line" do let(:knife_ssh) do |