From fd062bbca75c06b3867c97e8304535a59bec32ae Mon Sep 17 00:00:00 2001 From: Colin Jackson and Rasheed Abdul-Aziz Date: Mon, 23 Feb 2015 17:22:06 -0500 Subject: [PATCH] use lucid64 as the default stack when the DEA provides none [#88174340] --- lib/dependencies.rb | 6 +- .../compile_extensions/dependencies_spec.rb | 72 +++++++++++++++---- 2 files changed, 63 insertions(+), 15 deletions(-) diff --git a/lib/dependencies.rb b/lib/dependencies.rb index e826122..f63d1ae 100644 --- a/lib/dependencies.rb +++ b/lib/dependencies.rb @@ -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 diff --git a/spec/unit/compile_extensions/dependencies_spec.rb b/spec/unit/compile_extensions/dependencies_spec.rb index d021cea..b88e39e 100644 --- a/spec/unit/compile_extensions/dependencies_spec.rb +++ b/spec/unit/compile_extensions/dependencies_spec.rb @@ -24,6 +24,11 @@ module CompileExtensions 'version' => '1', 'name' => 'both_stacks_widget' }, + { + 'match' => /lucid_stack_widget/, + 'version' => '1', + 'name' => 'lucid_stack_widget' + }, ], 'dependencies' => [ { @@ -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