Skip to content

Commit

Permalink
Merge pull request #3249 from cloudfoundry/buildpack_stack_name
Browse files Browse the repository at this point in the history
Add stack name to unknown buildpack error message
  • Loading branch information
philippthun authored Apr 17, 2023
2 parents 6c33830 + d5d0ee5 commit ac93a74
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ def buildpacks_are_uri_or_nil
next if buildpack_info.buildpack.nil?
next if buildpack_info.buildpack_url

errors.add(:buildpack, %("#{buildpack_info.buildpack}" must be an existing admin buildpack or a valid git URI))
if stack
errors.add(:buildpack, %("#{buildpack_info.buildpack}" for stack "#{stack.name}" must be an existing admin buildpack or a valid git URI))
else
errors.add(:buildpack, %("#{buildpack_info.buildpack}" must be an existing admin buildpack or a valid git URI))
end
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ module VCAP::CloudController
end
end

context 'when stack is nil and buildpack is nonexistant' do
let(:stack) { nil }
let(:buildpack_name_or_url) { 'nonexistant_buildpack' }
let(:buildpack) { nil }

it 'is not valid' do
expect(validator).not_to be_valid
expect(validator.errors_on(:stack)).to include('must be an existing stack')
expect(validator.errors_on(:buildpack)).to include('"nonexistant_buildpack" must be an existing admin buildpack or a valid git URI')
end
end

context 'when given a buildpack url' do
let(:buildpack_name_or_url) { 'http://yeah.com' }
let(:buildpack) { nil }
Expand Down Expand Up @@ -63,10 +75,11 @@ module VCAP::CloudController

context 'when given an invalid BuildpackInfo' do
let(:buildpack_infos) { [buildpack_info, BuildpackInfo.new('invalid-bp', nil)] }
let(:stack) { Stack.make(name: 'existing_stack') }

it 'includes an error for the invalid buildpack' do
expect(validator).not_to be_valid
expect(validator.errors[:buildpack]).to include('"invalid-bp" must be an existing admin buildpack or a valid git URI')
expect(validator.errors[:buildpack]).to include('"invalid-bp" for stack "existing_stack" must be an existing admin buildpack or a valid git URI')
end
end
end
Expand Down

0 comments on commit ac93a74

Please sign in to comment.