Teach GoogleApi::CloudPlatform::Client#projects_zones_clusters_create about legacy_abac argument
Fix spec warning: removing `initialize' may cause serious problems Actually verify that `service.create_cluster` is called with expected request_body and other args
This commit is contained in:
parent
ab6d74da9a
commit
2e47e1f80e
3 changed files with 44 additions and 11 deletions
|
@ -27,7 +27,9 @@ module Clusters
|
|||
provider.zone,
|
||||
provider.cluster.name,
|
||||
provider.num_nodes,
|
||||
machine_type: provider.machine_type)
|
||||
machine_type: provider.machine_type,
|
||||
legacy_abac: true
|
||||
)
|
||||
|
||||
unless operation.status == 'PENDING' || operation.status == 'RUNNING'
|
||||
return provider.make_errored!("Operation status is unexpected; #{operation.status_message}")
|
||||
|
|
|
@ -50,7 +50,7 @@ module GoogleApi
|
|||
service.get_zone_cluster(project_id, zone, cluster_id, options: user_agent_header)
|
||||
end
|
||||
|
||||
def projects_zones_clusters_create(project_id, zone, cluster_name, cluster_size, machine_type:)
|
||||
def projects_zones_clusters_create(project_id, zone, cluster_name, cluster_size, machine_type:, legacy_abac:)
|
||||
service = Google::Apis::ContainerV1::ContainerService.new
|
||||
service.authorization = access_token
|
||||
|
||||
|
@ -63,7 +63,7 @@ module GoogleApi
|
|||
"machine_type": machine_type
|
||||
},
|
||||
"legacy_abac": {
|
||||
"enabled": true
|
||||
"enabled": legacy_abac
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,25 +66,30 @@ describe GoogleApi::CloudPlatform::Client do
|
|||
describe '#projects_zones_clusters_create' do
|
||||
subject do
|
||||
client.projects_zones_clusters_create(
|
||||
spy, spy, cluster_name, cluster_size, machine_type: machine_type)
|
||||
project_id, zone, cluster_name, cluster_size, machine_type: machine_type, legacy_abac: legacy_abac)
|
||||
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(:create_cluster_request_body) { double('Google::Apis::ContainerV1::CreateClusterRequest') }
|
||||
let(:operation) { double }
|
||||
|
||||
before do
|
||||
allow_any_instance_of(Google::Apis::ContainerV1::ContainerService)
|
||||
.to receive(:create_cluster).with(any_args, options: user_agent_options)
|
||||
.to receive(:create_cluster).with(any_args)
|
||||
.and_return(operation)
|
||||
end
|
||||
|
||||
it { is_expected.to eq(operation) }
|
||||
|
||||
it 'sets corresponded parameters' do
|
||||
expect_any_instance_of(Google::Apis::ContainerV1::CreateClusterRequest)
|
||||
.to receive(:initialize).with(
|
||||
expect_any_instance_of(Google::Apis::ContainerV1::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,
|
||||
|
@ -96,9 +101,35 @@ describe GoogleApi::CloudPlatform::Client do
|
|||
"enabled": true
|
||||
}
|
||||
}
|
||||
} )
|
||||
} ).and_return(create_cluster_request_body)
|
||||
|
||||
subject
|
||||
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::ContainerV1::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
|
||||
},
|
||||
"legacy_abac": {
|
||||
"enabled": false
|
||||
}
|
||||
}
|
||||
} ).and_return(create_cluster_request_body)
|
||||
|
||||
expect(subject).to eq operation
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue