Skip to content

Commit

Permalink
Provide more helpful error messages when you need to provide more det…
Browse files Browse the repository at this point in the history
…ails

There isn't a help command for this CLI so this message in its current form is pretty useless.

Signed-off-by: Tim Smith <tsmith@chef.io>
  • Loading branch information
tas50 committed Mar 11, 2021
1 parent 08ca9f8 commit d21624e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/mixlib/install/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def validate_user_agent_headers
def validate_platform_options
unless all_or_none?(platform_info.values)
errors << <<-EOS
Must provide platform, platform version and architecture when specifying any platform details
Must provide platform (-p), platform version (-l) and architecture (-a) when specifying any platform details
EOS
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/functional/mixlib/install/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
let(:architecture) { nil }

it "fails with missing args error" do
expect(last_command_started).to have_output /Must provide platform, platform version and architecture when specifying any platform details/
expect(last_command_started).to have_output /Must provide platform (-p), platform version (-l) and architecture (-a) when specifying any platform details/
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/unit/mixlib/install/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@
let(:platform) { "ubuntu" }

it "raises platform options error" do
expect { Mixlib::Install.new(product_name: product_name, channel: channel, platform: platform) }.to raise_error(Mixlib::Install::Options::InvalidOptions, /Must provide platform, platform version and architecture/)
expect { Mixlib::Install.new(product_name: product_name, channel: channel, platform: platform) }.to raise_error(Mixlib::Install::Options::InvalidOptions, /Must provide platform \(-p\), platform version \(-l\) and architecture \(-a\) when specifying any platform details/)
end

context "and with platform version" do
let(:platform_version) { "14.04" }

it "raises platform options error" do
expect { Mixlib::Install.new(product_name: product_name, channel: channel, platform: platform, platform_version: platform_version) }.to raise_error(Mixlib::Install::Options::InvalidOptions, /Must provide platform, platform version and architecture/)
expect { Mixlib::Install.new(product_name: product_name, channel: channel, platform: platform, platform_version: platform_version) }.to raise_error(Mixlib::Install::Options::InvalidOptions, /Must provide platform \(-p\), platform version \(-l\) and architecture \(-a\) when specifying any platform details/)
end
end
end
Expand All @@ -107,7 +107,7 @@
let(:architecture) { "i386" }

it "raises platform options error" do
expect { Mixlib::Install.new(product_name: product_name, channel: channel, architecture: architecture) }.to raise_error(Mixlib::Install::Options::InvalidOptions, /Must provide platform, platform version and architecture/)
expect { Mixlib::Install.new(product_name: product_name, channel: channel, architecture: architecture) }.to raise_error(Mixlib::Install::Options::InvalidOptions, /Must provide platform \(-p\), platform version \(-l\) and architecture \(-a\) when specifying any platform details/)
end
end
end
Expand Down

0 comments on commit d21624e

Please sign in to comment.