diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/lib/google_api/cloud_platform/client_spec.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/lib/google_api/cloud_platform/client_spec.rb')
-rw-r--r-- | spec/lib/google_api/cloud_platform/client_spec.rb | 145 |
1 files changed, 0 insertions, 145 deletions
diff --git a/spec/lib/google_api/cloud_platform/client_spec.rb b/spec/lib/google_api/cloud_platform/client_spec.rb index 82ab6c089da..4ea395830ad 100644 --- a/spec/lib/google_api/cloud_platform/client_spec.rb +++ b/spec/lib/google_api/cloud_platform/client_spec.rb @@ -6,7 +6,6 @@ require 'google/apis/sqladmin_v1beta4' RSpec.describe GoogleApi::CloudPlatform::Client do let(:token) { 'token' } let(:client) { described_class.new(token, nil) } - let(:user_agent_options) { client.instance_eval { user_agent_header } } let(:gcp_project_id) { String('gcp_proj_id') } let(:operation) { true } let(:database_instance) { Google::Apis::SqladminV1beta4::DatabaseInstance.new(state: 'RUNNABLE') } @@ -77,150 +76,6 @@ RSpec.describe GoogleApi::CloudPlatform::Client do end end - describe '#projects_zones_clusters_get' do - subject { client.projects_zones_clusters_get(spy, spy, spy) } - - let(:gke_cluster) { double } - - before do - allow_any_instance_of(Google::Apis::ContainerV1::ContainerService) - .to receive(:get_zone_cluster).with(any_args, options: user_agent_options) - .and_return(gke_cluster) - end - - it { is_expected.to eq(gke_cluster) } - end - - describe '#projects_zones_clusters_create' do - subject do - client.projects_zones_clusters_create( - project_id, zone, cluster_name, cluster_size, machine_type: machine_type, legacy_abac: legacy_abac, enable_addons: enable_addons) - end - - let(:project_id) { 'project-123' } - let(:zone) { 'us-central1-a' } - let(:cluster_name) { 'test-cluster' } - let(:cluster_size) { 1 } - let(:machine_type) { 'n1-standard-2' } - let(:legacy_abac) { true } - let(:enable_addons) { [] } - - let(:addons_config) do - enable_addons.index_with do - { disabled: false } - end - end - - let(:cluster_options) do - { - cluster: { - name: cluster_name, - initial_node_count: cluster_size, - node_config: { - machine_type: machine_type, - oauth_scopes: [ - "https://www.googleapis.com/auth/devstorage.read_only", - "https://www.googleapis.com/auth/logging.write", - "https://www.googleapis.com/auth/monitoring" - ] - }, - master_auth: { - client_certificate_config: { - issue_client_certificate: true - } - }, - legacy_abac: { - enabled: legacy_abac - }, - ip_allocation_policy: { - use_ip_aliases: true, - cluster_ipv4_cidr_block: '/16' - }, - addons_config: addons_config - } - } - end - - let(:create_cluster_request_body) { double('Google::Apis::ContainerV1beta1::CreateClusterRequest') } - let(:operation) { double } - - before do - allow_any_instance_of(Google::Apis::ContainerV1beta1::ContainerService) - .to receive(:create_cluster).with(any_args) - .and_return(operation) - end - - it 'sets corresponded parameters' do - expect_any_instance_of(Google::Apis::ContainerV1beta1::ContainerService) - .to receive(:create_cluster).with(project_id, zone, create_cluster_request_body, options: user_agent_options) - - expect(Google::Apis::ContainerV1beta1::CreateClusterRequest) - .to receive(:new).with(cluster_options).and_return(create_cluster_request_body) - - expect(subject).to eq operation - end - - context 'create without legacy_abac' do - let(:legacy_abac) { false } - - it 'sets corresponded parameters' do - expect_any_instance_of(Google::Apis::ContainerV1beta1::ContainerService) - .to receive(:create_cluster).with(project_id, zone, create_cluster_request_body, options: user_agent_options) - - expect(Google::Apis::ContainerV1beta1::CreateClusterRequest) - .to receive(:new).with(cluster_options).and_return(create_cluster_request_body) - - expect(subject).to eq operation - end - end - - context 'create with enable_addons for cloud_run' do - let(:enable_addons) { [:http_load_balancing, :istio_config, :cloud_run_config] } - - it 'sets corresponded parameters' do - expect_any_instance_of(Google::Apis::ContainerV1beta1::ContainerService) - .to receive(:create_cluster).with(project_id, zone, create_cluster_request_body, options: user_agent_options) - - expect(Google::Apis::ContainerV1beta1::CreateClusterRequest) - .to receive(:new).with(cluster_options).and_return(create_cluster_request_body) - - expect(subject).to eq operation - end - end - end - - describe '#projects_zones_operations' do - subject { client.projects_zones_operations(spy, spy, spy) } - - let(:operation) { double } - - before do - allow_any_instance_of(Google::Apis::ContainerV1::ContainerService) - .to receive(:get_zone_operation).with(any_args, options: user_agent_options) - .and_return(operation) - end - - it { is_expected.to eq(operation) } - end - - describe '#parse_operation_id' do - subject { client.parse_operation_id(self_link) } - - context 'when expected url' do - let(:self_link) do - 'projects/gcp-project-12345/zones/us-central1-a/operations/ope-123' - end - - it { is_expected.to eq('ope-123') } - end - - context 'when unexpected url' do - let(:self_link) { '???' } - - it { is_expected.to be_nil } - end - end - describe '#user_agent_header' do subject { client.instance_eval { user_agent_header } } |