Skip to content

Commit

Permalink
Merge pull request #352 from chef/better_errors
Browse files Browse the repository at this point in the history
Provide more helpful error messages when you need to provide more details
  • Loading branch information
tduffield committed May 5, 2021
2 parents 78f88d1 + ede2f40 commit 04e9e68
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 04e9e68

Please sign in to comment.