From 5465f7ed0727937e7acbb7e4b08d88e1087363df Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Wed, 13 Mar 2019 17:59:24 +0000 Subject: [PATCH] Add test and alias for BigQuery Dataset name Signed-off-by: Modular Magician --- docs/resources/google_bigquery_dataset.md | 3 +-- libraries/google_bigquery_dataset.rb | 6 ++++-- test/integration/verify/controls/google_bigquery_dataset.rb | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/resources/google_bigquery_dataset.md b/docs/resources/google_bigquery_dataset.md index ab2edc4a0..557805371 100644 --- a/docs/resources/google_bigquery_dataset.md +++ b/docs/resources/google_bigquery_dataset.md @@ -14,6 +14,7 @@ describe google_bigquery_dataset(project: 'chef-gcp-inspec', name: 'inspec_gcp_d its('friendly_name') { should eq 'A BigQuery dataset test' } its('location') { should eq 'EU' } its('description') { should eq 'Test BigQuery dataset description' } + its('name') { should eq 'inspec_gcp_dataset' } its('default_table_expiration_ms') { should cmp '3600000' } end @@ -34,8 +35,6 @@ end ## Properties Properties that can be accessed from the `google_bigquery_dataset` resource: - * `name`: Dataset name - * `access`: Access controls on the bucket. * `domain`: A domain to grant access to. Any users signed in with the domain specified will be granted the specified access diff --git a/libraries/google_bigquery_dataset.rb b/libraries/google_bigquery_dataset.rb index 452a91180..863dc2460 100644 --- a/libraries/google_bigquery_dataset.rb +++ b/libraries/google_bigquery_dataset.rb @@ -23,7 +23,6 @@ class Dataset < GcpResourceBase desc 'Dataset' supports platform: 'gcp' - attr_reader :name attr_reader :access attr_reader :creation_time attr_reader :dataset_reference @@ -42,7 +41,6 @@ def initialize(params) end def parse - @name = @fetched['name'] @access = GoogleInSpec::BigQuery::Property::DatasetAccessArray.parse(@fetched['access']) @creation_time = @fetched['creationTime'] @dataset_reference = GoogleInSpec::BigQuery::Property::DatasetDatasetReference.new(@fetched['datasetReference']) @@ -64,6 +62,10 @@ def exists? !@fetched.nil? end + def name + dataset_reference&.dataset_id + end + private def product_url diff --git a/test/integration/verify/controls/google_bigquery_dataset.rb b/test/integration/verify/controls/google_bigquery_dataset.rb index 6e4e325ab..7d9963430 100644 --- a/test/integration/verify/controls/google_bigquery_dataset.rb +++ b/test/integration/verify/controls/google_bigquery_dataset.rb @@ -34,6 +34,7 @@ its('friendly_name') { should eq dataset['friendly_name'] } its('location') { should eq dataset['location'] } its('description') { should eq dataset['description'] } + its('name') { should eq dataset['dataset_id'] } its('default_table_expiration_ms') { should cmp dataset['default_table_expiration_ms'] } end