Skip to content

Commit

Permalink
Fixes according to issues: #19, #20, #21 and #22.
Browse files Browse the repository at this point in the history
* Ensure resources have consistent exists methods.
* Corrected a coupld of arguments in example doc strings.

Signed-off-by: Stuart Paterson <spaterson@chef.io>
  • Loading branch information
Stuart Paterson committed Jun 11, 2018
1 parent 804e067 commit 9a92acc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions libraries/google_compute_firewall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def ports_protocol_allowed(port_list, protocol = 'tcp', index = 0)
end
end

def exists?
!@firewall.nil?
end

def to_s
"Firewall Rule #{@display_name}"
end
Expand Down
4 changes: 4 additions & 0 deletions libraries/google_compute_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def initialize(opts = {})
end
end

def exists?
!@image.nil?
end

def to_s
"Image #{@display_name}"
end
Expand Down
6 changes: 5 additions & 1 deletion libraries/google_compute_instance_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class GoogleComputeInstanceGroup < GcpResourceBase
desc 'Verifies settings for a compute instance group'

example "
describe google_compute_instance_group(project: 'chef-inspec-gcp', location: 'us-west2', name: 'gcp-inspec-test') do
describe google_compute_instance_group(project: 'chef-inspec-gcp', zone: 'europe-west2-a', name: 'gcp-inspec-test') do
it { should exist }
its('name') { should eq 'inspec-test' }
its('status') { should eq 'in_use' }
Expand Down Expand Up @@ -38,6 +38,10 @@ def get_named_ports(index = 0, key = :name)
named_ports[index].item[key]
end

def exists?
!@instance_group.nil?
end

def to_s
"Instance Group #{@display_name}"
end
Expand Down
2 changes: 1 addition & 1 deletion libraries/google_container_node_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class GoogleContainerNodePool < GcpResourceBase
desc 'Verifies settings for a container nodepool'

example "
describe gcp_container_nodepool(project: 'chef-inspec-gcp', zone: 'gcp-inspec-test', name: 'cluster-name') do
describe google_container_node_pool(project: 'chef-inspec-gcp', zone: 'gcp-inspec-test', cluster_name: 'cluster-name', nodepool_name: 'nodepool_name') do
it { should exist }
its('name') { should eq 'inspec-test' }
its('status') { should eq 'in_use' }
Expand Down
2 changes: 1 addition & 1 deletion libraries/google_service_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def initialize(opts = {})
end

def exists?
!@iam_role.nil?
!@service_account.nil?
end

def to_s
Expand Down

0 comments on commit 9a92acc

Please sign in to comment.