1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
|
#
# Copyright:: Copyright (c) 2016-2018 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require "spec_helper"
require "mixlib/install/cli"
describe "mixlib-install executable", :type => :aruba do
let(:args) { nil }
before(:all) do
puts "
****************************************
TESTS ARE SLOW - DOWNLOADS PACKAGES.
****************************************
"
end
before(:each) { run("bin/mixlib-install #{command} #{args}") }
describe "version command" do
let(:command) { "version" }
xit "prints the mixlib-install version" do
require "mixlib/install/version"
expect(last_command_started).to have_output Mixlib::Install::VERSION
end
end
describe "list-versions command" do
let(:command) { "list-versions" }
around do |example|
with_proxy_server do
ClimateControl.modify http_proxy: "http://127.0.0.1:8401", https_proxy: "http://127.0.0.1:8401" do
example.run
end
end
end
context "with valid args" do
let(:args) { "chef stable" }
xit "prints the versions" do
expect(last_command_started).to have_output /12.0.3/
end
end
context "with invalid args" do
let(:args) { "foo bar" }
xit "returns error message" do
expect(last_command_started).to have_output /Unknown product name foo/
expect(last_command_started).to have_output /Unknown channel bar/
end
end
end
describe "install-script command" do
let(:command) { "install-script" }
context "with no args" do
xit "returns shell script to stdout" do
expect(last_command_started).to have_output /end of install_package.sh/
end
end
context "with ps1 type" do
let(:args) { "-t ps1" }
xit "returns powershell script to stdout" do
expect(last_command_started).to have_output /export-modulemember -function 'Install-Project','Get-ProjectMetadata' -alias 'install'/
end
end
context "with invalid type" do
let(:args) { "-t foo" }
xit "errors an error" do
expect(last_command_started).to have_output "Expected '--type' to be one of ps1, sh; got foo"
end
end
context "with alternate endpoint" do
let(:args) { "--endpoint https://omnitruck-custom.chef.io" }
xit "contains the new endpoint" do
expect(last_command_started).to have_output /https:\/\/omnitruck-custom.chef.io/
end
end
context "with output option" do
let(:args) { "-o script.sh" }
xit "writes to a file" do
expect("script.sh").to be_an_existing_file
end
end
end
describe "download command" do
let(:command) { "download" }
let(:additional_args) { nil }
let(:args) do
a = ""
a << product unless product.nil?
a << " -p #{platform}" unless platform.nil?
a << " -l #{platform_version}" unless platform_version.nil?
a << " -a #{architecture}" unless architecture.nil?
a << " #{additional_args}" unless additional_args.nil?
a
end
let(:product) { "chef" }
let(:platform) { "ubuntu" }
let(:platform_version) { "14.04" }
let(:architecture) { "x86_64" }
around do |example|
with_proxy_server do
ClimateControl.modify http_proxy: "http://127.0.0.1:8401", https_proxy: "http://127.0.0.1:8401" do
example.run
end
end
end
context "without args" do
let(:product) { nil }
let(:platform) { nil }
let(:platform_version) { nil }
let(:architecture) { nil }
xit "exits with required args error" do
expect(last_command_started).to have_output /"mixlib-install #{command}" was called with no arguments/
end
end
context "with chef product" do
let(:product) { "chef" }
xit "downloads a chef artifact" do
expect(last_command_started).to have_output /Download saved to/
end
end
context "with url flag" do
let(:additional_args) { "--url" }
xit "outputs the url" do
expect(last_command_started).to have_output /https:\/\/packages.chef.io\/files\/stable\/chef/
end
end
context "with attributes arg" do
let(:additional_args) { "--url --attributes" }
xit "outputs the attributes" do
expect(last_command_started).to have_output /"license": "Chef EULA"/
end
end
context "with platform arg" do
let(:platform) { "ubuntu" }
let(:platform_version) { nil }
let(:architecture) { nil }
xit "fails with missing args error" do
expect(last_command_started).to have_output "Must provide platform (-p), platform version (-l) and architecture (-a) when specifying any platform details"
end
end
context "with future platform version" do
let(:platform) { "windows" }
let(:platform_version) { "2016" }
let(:additional_args) { "--attributes" }
let(:latest_version) { Mixlib::Install.available_versions("chefdk", "stable").last }
let(:filename) { "chefdk-#{latest_version}-x86.msi" }
xit "has the correct artifact" do
require "digest"
sha256 = Digest::SHA256.hexdigest("./tmp/aruba/#{filename}")
expect(last_command_started).to have_output /sha256/
end
end
context "with invalid platform version and architecture" do
let(:platform) { "foo" }
let(:platform_version) { "99.99" }
let(:architecture) { "x86_64" }
let(:additional_args) { "--no-platform-version-compat" }
xit "returns no results" do
expect(last_command_started).to have_output /No artifacts found matching criteria./
end
end
context "with specified version" do
let(:additional_args) { "-v 12.0.3" }
xit "returns the correct artifact" do
expect(last_command_started).to have_output /chef[-_]12.0.3-1/
end
end
context "with specified channel" do
let(:additional_args) { "-c current" }
xit "returns the correct artifact" do
expect(last_command_started).to have_output /files\/current\/chef/
end
end
context "with specified directory" do
let(:additional_args) { "-d mydir" }
xit "downloads to dir" do
expect(last_command_started).to have_output /Download saved to .*mydir\/chef/
end
end
end
end
|