Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Commit

Permalink
use lucid64 as the default stack when the DEA provides none
Browse files Browse the repository at this point in the history
[#88174340]
  • Loading branch information
Colin Jackson and Rasheed Abdul-Aziz authored and Anthony Emengo and Sai To Yeung committed Feb 26, 2015
1 parent 06cd382 commit fd062bb
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 15 deletions.
6 changes: 5 additions & 1 deletion lib/dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ def find_dependency_with_mapping(mapping)
def dependency_satisfies_current_stack(dependency)
return true if dependency['cf_stacks'] == ALL_STACKS_IDENTIFIER

dependency['cf_stacks'].include?(ENV['CF_STACK'])
dependency['cf_stacks'].include?(stack)
end

def stack
ENV['CF_STACK'] || 'lucid64'
end
end
end
72 changes: 58 additions & 14 deletions spec/unit/compile_extensions/dependencies_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ module CompileExtensions
'version' => '1',
'name' => 'both_stacks_widget'
},
{
'match' => /lucid_stack_widget/,
'version' => '1',
'name' => 'lucid_stack_widget'
},
],
'dependencies' => [
{
Expand All @@ -44,43 +49,82 @@ module CompileExtensions
'uri' => 'both_stacks_only',
'cf_stacks' => ['first', 'second']
},
{
'version' => '1',
'name' => 'lucid_stack_widget',
'uri' => 'lucid_stack_dep',
'cf_stacks' => ['lucid64']
},

]
}
end

context "first stack" do
let(:matching_dependency) { dependencies.find_matching_dependency(original_url) }

context 'environment uses first stack' do
before do
ENV['CF_STACK'] = 'first'
end

specify do
matching_dependency = dependencies.find_matching_dependency('first_stack_widget')
context 'dependency that only matches the first stack' do
let(:original_url) { 'first_stack_widget' }

expect(matching_dependency["uri"]).to eql('first_stack_only')
specify do
expect(matching_dependency['uri']).to eql('first_stack_only')
end
end

specify do
matching_dependency = dependencies.find_matching_dependency('any_stack_widget')
context 'dependency that will match any stack' do
let(:original_url) { 'any_stack_widget' }

expect(matching_dependency["uri"]).to eql('any_stack')
specify do
expect(matching_dependency['uri']).to eql('any_stack')
end
end
end

context "second stack" do
context 'environment uses second stack' do
before do
ENV['CF_STACK'] = 'second'
end

specify do
matching_dependency = dependencies.find_matching_dependency('first_stack_widget')
context 'dependency that only matches the first stack' do
let(:original_url) { 'first_stack_widget' }

specify do
expect(matching_dependency).to be_nil
end
end

context 'dependency that will match first or second stack' do
let(:original_url) { 'both_stacks_widget' }

specify do
expect(matching_dependency['uri']).to eql('both_stacks_only')
end
end
end

context 'environment does not tell us what stack it uses' do
before do
ENV.delete('CF_STACK')
end

context 'dependency that matches the lucid64 stack' do
let(:original_url) { 'lucid_stack_widget' }

expect(matching_dependency).to be_nil
specify do
expect(matching_dependency['uri']).to eql('lucid_stack_dep')
end
end

specify do
matching_dependency = dependencies.find_matching_dependency('both_stacks_widget')
context 'dependency that does not match the lucid64 stack' do
let(:original_url) { 'first_stack_widget' }

expect(matching_dependency['uri']).to eql('both_stacks_only')
specify do
expect(matching_dependency).to be_nil
end
end
end
end
Expand Down

0 comments on commit fd062bb

Please sign in to comment.