summaryrefslogtreecommitdiff
path: root/spec/services/google_cloud/gcp_region_add_or_replace_service_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-18 20:02:30 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-18 20:02:30 +0000
commit41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch)
tree9c8d89a8624828992f06d892cd2f43818ff5dcc8 /spec/services/google_cloud/gcp_region_add_or_replace_service_spec.rb
parent0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff)
downloadgitlab-ce-41fe97390ceddf945f3d967b8fdb3de4c66b7dea.tar.gz
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
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.rb28
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