summaryrefslogtreecommitdiff
path: root/spec/lib/google_api
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-23 00:06:29 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-23 00:06:29 +0000
commit98dbb0a488d7b0093f352938210d9578b0f7a8a6 (patch)
tree25654204f8de2672556a696199fa209b8f8ff1b3 /spec/lib/google_api
parent9ce26d3dfdf4194f32c470cd3102b4376a53ef2f (diff)
downloadgitlab-ce-98dbb0a488d7b0093f352938210d9578b0f7a8a6.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/google_api')
-rw-r--r--spec/lib/google_api/cloud_platform/client_spec.rb98
1 files changed, 53 insertions, 45 deletions
diff --git a/spec/lib/google_api/cloud_platform/client_spec.rb b/spec/lib/google_api/cloud_platform/client_spec.rb
index c24998d32f8..2253feb376d 100644
--- a/spec/lib/google_api/cloud_platform/client_spec.rb
+++ b/spec/lib/google_api/cloud_platform/client_spec.rb
@@ -68,7 +68,7 @@ describe GoogleApi::CloudPlatform::Client do
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)
+ 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' }
@@ -77,39 +77,51 @@ describe GoogleApi::CloudPlatform::Client do
let(:cluster_size) { 1 }
let(:machine_type) { 'n1-standard-2' }
let(:legacy_abac) { true }
- let(:create_cluster_request_body) { double('Google::Apis::ContainerV1::CreateClusterRequest') }
+ let(:enable_addons) { [] }
+
+ let(:addons_config) do
+ enable_addons.each_with_object({}) do |addon, hash|
+ hash[addon] = { disabled: false }
+ end
+ end
+
+ let(:cluster_options) do
+ {
+ cluster: {
+ name: cluster_name,
+ initial_node_count: cluster_size,
+ node_config: {
+ machine_type: machine_type
+ },
+ master_auth: {
+ username: 'admin',
+ client_certificate_config: {
+ issue_client_certificate: true
+ }
+ },
+ legacy_abac: {
+ enabled: legacy_abac
+ },
+ 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::ContainerV1::ContainerService)
+ 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::ContainerV1::ContainerService)
+ 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::ContainerV1::CreateClusterRequest)
- .to receive(:new).with(
- {
- "cluster": {
- "name": cluster_name,
- "initial_node_count": cluster_size,
- "node_config": {
- "machine_type": machine_type
- },
- "master_auth": {
- "username": "admin",
- "client_certificate_config": {
- issue_client_certificate: true
- }
- },
- "legacy_abac": {
- "enabled": true
- }
- }
- } ).and_return(create_cluster_request_body)
+ expect(Google::Apis::ContainerV1beta1::CreateClusterRequest)
+ .to receive(:new).with(cluster_options).and_return(create_cluster_request_body)
expect(subject).to eq operation
end
@@ -118,29 +130,25 @@ describe GoogleApi::CloudPlatform::Client do
let(:legacy_abac) { false }
it 'sets corresponded parameters' do
- expect_any_instance_of(Google::Apis::ContainerV1::ContainerService)
+ 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::ContainerV1::CreateClusterRequest)
- .to receive(:new).with(
- {
- "cluster": {
- "name": cluster_name,
- "initial_node_count": cluster_size,
- "node_config": {
- "machine_type": machine_type
- },
- "master_auth": {
- "username": "admin",
- "client_certificate_config": {
- issue_client_certificate: true
- }
- },
- "legacy_abac": {
- "enabled": false
- }
- }
- } ).and_return(create_cluster_request_body)
+ expect(Google::Apis::ContainerV1beta1::CreateClusterRequest)
+ .to receive(:new).with(cluster_options).and_return(create_cluster_request_body)
expect(subject).to eq operation
end