From 991e4294dda89dbc2cf64ca5276dd047e50a5cde Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Fri, 11 Jan 2019 00:28:09 +0000 Subject: [PATCH] Add negative tests for nonexistent resources Signed-off-by: Modular Magician --- docs/resources/google_compute_disk.md | 4 ++++ docs/resources/google_compute_ssl_policy.md | 4 ++++ docs/resources/google_pubsub_subscription.md | 4 ++++ docs/resources/google_pubsub_topic.md | 3 +++ test/integration/verify/controls/google_compute_disk.rb | 4 ++++ test/integration/verify/controls/google_compute_ssl_policy.rb | 4 ++++ .../integration/verify/controls/google_pubsub_subscription.rb | 4 ++++ test/integration/verify/controls/google_pubsub_topic.rb | 4 ++++ 8 files changed, 31 insertions(+) diff --git a/docs/resources/google_compute_disk.md b/docs/resources/google_compute_disk.md index 638db57c6..7092047a7 100644 --- a/docs/resources/google_compute_disk.md +++ b/docs/resources/google_compute_disk.md @@ -26,6 +26,10 @@ describe.one do end end end + +describe google_compute_disk(project: 'chef-gcp-inspec', name: 'nonexistent', zone: 'zone') do + it { should_not exist } +end ``` ## Properties diff --git a/docs/resources/google_compute_ssl_policy.md b/docs/resources/google_compute_ssl_policy.md index 3df415f5d..827066f17 100644 --- a/docs/resources/google_compute_ssl_policy.md +++ b/docs/resources/google_compute_ssl_policy.md @@ -16,6 +16,10 @@ describe google_compute_ssl_policy(project: 'chef-gcp-inspec', name: 'inspec-gcp its('custom_features') { should include 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384' } its('custom_features') { should include 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384' } end + +describe google_compute_ssl_policy(project: 'chef-gcp-inspec', name: 'nonexistent') do + it { should_not exist } +end ``` ## Properties diff --git a/docs/resources/google_pubsub_subscription.md b/docs/resources/google_pubsub_subscription.md index 71dd45121..dec130338 100644 --- a/docs/resources/google_pubsub_subscription.md +++ b/docs/resources/google_pubsub_subscription.md @@ -13,6 +13,10 @@ describe google_pubsub_subscription(project: '', name: 'inspec-gcp-subscription' it { should exist } end +describe google_pubsub_subscription(project: '', name: 'nonexistent') do + it { should_not exist } +end + ``` ## Properties diff --git a/docs/resources/google_pubsub_topic.md b/docs/resources/google_pubsub_topic.md index 622a8f8c2..62a7e07db 100644 --- a/docs/resources/google_pubsub_topic.md +++ b/docs/resources/google_pubsub_topic.md @@ -13,6 +13,9 @@ describe google_pubsub_topic(project: '', name: 'inspec-gcp-topic') do it { should exist } end +describe google_pubsub_topic(project: '', name: 'nonexistent') do + it { should_not exist } +end ``` ## Properties diff --git a/test/integration/verify/controls/google_compute_disk.rb b/test/integration/verify/controls/google_compute_disk.rb index c0cf721ae..bd85f53af 100644 --- a/test/integration/verify/controls/google_compute_disk.rb +++ b/test/integration/verify/controls/google_compute_disk.rb @@ -40,4 +40,8 @@ end end end + + describe google_compute_disk(project: gcp_project_id, name: 'nonexistent', zone: gcp_zone) do + it { should_not exist } + end end diff --git a/test/integration/verify/controls/google_compute_ssl_policy.rb b/test/integration/verify/controls/google_compute_ssl_policy.rb index 971c667f4..af6a3b57e 100644 --- a/test/integration/verify/controls/google_compute_ssl_policy.rb +++ b/test/integration/verify/controls/google_compute_ssl_policy.rb @@ -33,4 +33,8 @@ its('custom_features') { should include ssl_policy['custom_feature'] } its('custom_features') { should include ssl_policy['custom_feature2'] } end + + describe google_compute_ssl_policy(project: gcp_project_id, name: 'nonexistent') do + it { should_not exist } + end end diff --git a/test/integration/verify/controls/google_pubsub_subscription.rb b/test/integration/verify/controls/google_pubsub_subscription.rb index bde2c6cd8..c781b654a 100644 --- a/test/integration/verify/controls/google_pubsub_subscription.rb +++ b/test/integration/verify/controls/google_pubsub_subscription.rb @@ -24,4 +24,8 @@ describe google_pubsub_subscription(project: gcp_project_id, name: subscription['name']) do it { should exist } end + + describe google_pubsub_subscription(project: gcp_project_id, name: 'nonexistent') do + it { should_not exist } + end end diff --git a/test/integration/verify/controls/google_pubsub_topic.rb b/test/integration/verify/controls/google_pubsub_topic.rb index c4e1c895b..b580593e6 100644 --- a/test/integration/verify/controls/google_pubsub_topic.rb +++ b/test/integration/verify/controls/google_pubsub_topic.rb @@ -24,4 +24,8 @@ describe google_pubsub_topic(project: gcp_project_id, name: topic['name']) do it { should exist } end + + describe google_pubsub_topic(project: gcp_project_id, name: 'nonexistent') do + it { should_not exist } + end end