diff options
Diffstat (limited to 'spec/services/google_cloud/gcp_region_add_or_replace_service_spec.rb')
-rw-r--r-- | spec/services/google_cloud/gcp_region_add_or_replace_service_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/services/google_cloud/gcp_region_add_or_replace_service_spec.rb b/spec/services/google_cloud/gcp_region_add_or_replace_service_spec.rb new file mode 100644 index 00000000000..e2f5a2e719e --- /dev/null +++ b/spec/services/google_cloud/gcp_region_add_or_replace_service_spec.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GoogleCloud::GcpRegionAddOrReplaceService do + it 'adds and replaces GCP region vars' do + project = create(:project, :public) + service = described_class.new(project) + + service.execute('env_1', 'loc_1') + service.execute('env_2', 'loc_2') + service.execute('env_1', 'loc_3') + + list = project.variables.reload.filter { |variable| variable.key == Projects::GoogleCloudController::GCP_REGION_CI_VAR_KEY } + list = list.sort_by(&:environment_scope) + + aggregate_failures 'testing list of gcp regions' do + expect(list.length).to eq(2) + + # asserting that the first region is replaced + expect(list.first.environment_scope).to eq('env_1') + expect(list.first.value).to eq('loc_3') + + expect(list.second.environment_scope).to eq('env_2') + expect(list.second.value).to eq('loc_2') + end + end +end |