summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMarc A. Paradise <marc.paradise@gmail.com>2019-05-03 17:28:02 -0400
committerMarc A. Paradise <marc.paradise@gmail.com>2019-05-03 18:05:49 -0400
commita1c438aa2b15b310ecccd062ae714026f39d3f12 (patch)
tree8c1e21b43837d3f5dc3bfbdacc66f3caea177180 /spec
parent4dde88da4d24148987ca80b3dd7a5f802516f68d (diff)
downloadchef-a1c438aa2b15b310ecccd062ae714026f39d3f12.tar.gz
Pass channel directly into the script/url to determine Chef Infra downloadmp/bootstrap/restore-prerelease
Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/knife/core/bootstrap_context_spec.rb63
-rw-r--r--spec/unit/knife/core/windows_bootstrap_context_spec.rb49
2 files changed, 37 insertions, 75 deletions
diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb
index d3db342257..d57e254793 100644
--- a/spec/unit/knife/core/bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/bootstrap_context_spec.rb
@@ -156,45 +156,6 @@ describe Chef::Knife::Core::BootstrapContext do
end
end
- describe "when a bootstrap_version is specified" do
- let(:chef_config) do
- {
- knife: { bootstrap_version: "11.12.4" },
- }
- end
-
- 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" } }
-
- 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: "16.2.2" },
- }
- end
-
- 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 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.
- expect(bootstrap_context.latest_current_chef_version_string).to eq("-v #{Chef::VERSION.to_i}")
- end
- end
-
describe "ssl_verify_mode" do
it "isn't set in the config_content by default" do
expect(bootstrap_context.config_content).not_to include("ssl_verify_mode")
@@ -312,4 +273,28 @@ describe Chef::Knife::Core::BootstrapContext do
end
end
+
+ describe "#version_to_install" do
+ context "when bootstrap_version is provided" do
+ let(:chef_config) { { knife: { bootstrap_version: "awesome" } } }
+
+ it "returns bootstrap_version" do
+ expect(bootstrap_context.version_to_install).to eq "awesome"
+ end
+ end
+
+ context "when bootstrap_version is not provided" do
+ let(:config) { { channel: "stable" } }
+ it "returns the currently running major version out of Chef::VERSION" do
+ expect(bootstrap_context.version_to_install).to eq Chef::VERSION.split(".").first
+ end
+ end
+
+ context "and channel is other than stable" do
+ let(:config) { { channel: "unstable" } }
+ it "returns the version string 'latest'" do
+ expect(bootstrap_context.version_to_install).to eq "latest"
+ end
+ end
+ end
end
diff --git a/spec/unit/knife/core/windows_bootstrap_context_spec.rb b/spec/unit/knife/core/windows_bootstrap_context_spec.rb
index ea6609a0bf..7bc73c113a 100644
--- a/spec/unit/knife/core/windows_bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/windows_bootstrap_context_spec.rb
@@ -176,53 +176,30 @@ describe Chef::Knife::Core::WindowsBootstrapContext do
end
end
- describe "latest_current_windows_chef_version_query" do
- it "includes the major version of the current version of Chef" do
- stub_const("Chef::VERSION", "15.1.2")
- expect(bootstrap_context.latest_current_windows_chef_version_query).to eq("&v=15")
- end
-
- context "when bootstrap_version is given" do
- before do
- Chef::Config[:knife][:bootstrap_version] = "15.1.2"
- end
- it "includes the requested version" do
- expect(bootstrap_context.latest_current_windows_chef_version_query).to eq("&v=15.1.2")
- end
- end
-
- 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
- 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
-
- end
-
describe "msi_url" do
- context "when config option is not set" do
+ context "when msi_url config option is not set" do
+ let(:config) { { channel: "stable" } }
before do
- expect(bootstrap_context).to receive(:latest_current_windows_chef_version_query).and_return("&v=something")
+ expect(bootstrap_context).to receive(:version_to_install).and_return("something")
end
it "returns a chef.io msi url with minimal url parameters" do
- reference_url = "https://www.chef.io/chef/download?p=windows&v=something"
+ reference_url = "https://www.chef.io/chef/download?p=windows&channel=stable&v=something"
expect(bootstrap_context.msi_url).to eq(reference_url)
end
it "returns a chef.io msi url with provided url parameters substituted" do
- reference_url = "https://www.chef.io/chef/download?p=windows&pv=machine&m=arch&DownloadContext=ctx&v=something"
+ reference_url = "https://www.chef.io/chef/download?p=windows&pv=machine&m=arch&DownloadContext=ctx&channel=stable&v=something"
expect(bootstrap_context.msi_url("machine", "arch", "ctx")).to eq(reference_url)
end
+
+ context "when a channel is provided in config" do
+ let(:config) { { channel: "current" } }
+ it "returns a chef.io msi url with the requested channel" do
+ reference_url = "https://www.chef.io/chef/download?p=windows&channel=current&v=something"
+ expect(bootstrap_context.msi_url).to eq(reference_url)
+ end
+ end
end
context "when msi_url config option is set" do