diff options
author | Marc A. Paradise <marc.paradise@gmail.com> | 2019-05-01 11:06:28 -0400 |
---|---|---|
committer | Marc A. Paradise <marc.paradise@gmail.com> | 2019-05-03 17:30:08 -0400 |
commit | f2d590eecc90da7a78593b61437dbac27a480322 (patch) | |
tree | 8f5e6dc0d0b1342b87381c6d26fedec05d60f0b0 /spec | |
parent | faeddcb492020f3ead4aa433e93a9903d16ab652 (diff) | |
download | chef-f2d590eecc90da7a78593b61437dbac27a480322.tar.gz |
`prerelease` -> `channel` in bootstrap contexts
Updates BootstrapContext and WindowsBootstrapContext to
expect a 'channel' config value instead of a 'prelease' value.
This removes the old behavior of inferring pre-release (current) from
the presence of a fourth version number in the version string (eg
1.2.3.pre) - that was specific to gem installs, and gem installs are not
used in bootstrap.
Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 10 | ||||
-rw-r--r-- | spec/unit/knife/core/bootstrap_context_spec.rb | 25 | ||||
-rw-r--r-- | spec/unit/knife/core/windows_bootstrap_context_spec.rb | 19 |
3 files changed, 22 insertions, 32 deletions
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index d82dc7614e..4261a3a166 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -1603,10 +1603,7 @@ describe Chef::Knife::Bootstrap do end context "when a deprecated CLI flag is given on the CLI" do - before do - knife.config[:ssh_user] = "sshuser" - knife.merge_configs - end + let(:bootstrap_cli_options) { %w{--ssh-user sshuser} } 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(/You provided --ssh-user. This flag is deprecated. Please use '--connection-user USERNAME' instead./) knife.verify_deprecated_flags! @@ -1616,11 +1613,6 @@ describe Chef::Knife::Bootstrap do context "when a deprecated CLI flag is given on the CLI, along with its replacement" do let(:bootstrap_cli_options) { %w{--connection-user a --ssh-user b} } - before do - knife.config[:ssh_user] = "sshuser" - knife.config[:connection_user] = "real-user" - knife.merge_configs - end 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) diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb index e72acf9b7a..d3db342257 100644 --- a/spec/unit/knife/core/bootstrap_context_spec.rb +++ b/spec/unit/knife/core/bootstrap_context_spec.rb @@ -163,32 +163,31 @@ describe Chef::Knife::Core::BootstrapContext do } end - it "should send the full version to the installer" do + it "should return full version installer specified with -v" do expect(bootstrap_context.latest_current_chef_version_string).to eq("-v 11.12.4") end + end + + describe "when current channel is specified" do + let(:config) { { channel: "current" } } - describe "and it is a prerelease version" do + it "should return only the -p flag" do + expect(bootstrap_context.latest_current_chef_version_string).to eq("-p") + end + context "and a bootstrap version is specified" do let(:chef_config) do { - knife: { bootstrap_version: "11.12.4.xyz" }, + knife: { bootstrap_version: "16.2.2" }, } end - it "should set the version and set -p" do - expect(bootstrap_context.latest_current_chef_version_string).to eq("-v 11.12.4.xyz -p") + it "should return both full version and prerelease flags" do + expect(bootstrap_context.latest_current_chef_version_string).to eq("-p -v 16.2.2") end end end - describe "when prerelease is specified" do - let(:config) { { prerelease: true } } - - it "should send -p to the installer" do - expect(bootstrap_context.latest_current_chef_version_string).to eq("-p") - end - end - describe "when a bootstrap_version is not specified" do it "should send the latest current to the installer" do # Intentionally hard coded in order not to replicate the logic. diff --git a/spec/unit/knife/core/windows_bootstrap_context_spec.rb b/spec/unit/knife/core/windows_bootstrap_context_spec.rb index a39a3a9242..ea6609a0bf 100644 --- a/spec/unit/knife/core/windows_bootstrap_context_spec.rb +++ b/spec/unit/knife/core/windows_bootstrap_context_spec.rb @@ -191,19 +191,18 @@ describe Chef::Knife::Core::WindowsBootstrapContext do end end - context "when prerelease is true" do - let(:config) { { prerelease: true } } + context "when channel is current" do + let(:config) { { channel: "current" } } it "includes prerelease indicator " do expect(bootstrap_context.latest_current_windows_chef_version_query).to eq("&prerelease=true") end - end - - context "when a prerelease bootstrap_version is specified" do - before do - Chef::Config[:knife][:bootstrap_version] = "15.1.2.xyz" - end - it "includes prerelease indicator and the given version" do - expect(bootstrap_context.latest_current_windows_chef_version_query).to eq("&v=15.1.2.xyz&prerelease=true") + context "and bootstrap_version is given" do + before do + Chef::Config[:knife][:bootstrap_version] = "16.2.2" + end + it "includes the requested version" do + expect(bootstrap_context.latest_current_windows_chef_version_query).to eq("&prerelease=true&v=16.2.2") + end end end |