Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Add test and alias for BigQuery Dataset name
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
slevenick authored and modular-magician committed Mar 13, 2019
1 parent baa73be commit 42ad8e8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/resources/google_bigquery_dataset.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/resources/google_bigquery_tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ See [google_bigquery_table.md](google_bigquery_table.md) for more detailed infor
* `labels`: an array of `google_bigquery_table` labels
* `last_modified_times`: an array of `google_bigquery_table` last_modified_time
* `locations`: an array of `google_bigquery_table` location
* `names`: an array of `google_bigquery_table` name
* `num_bytes`: an array of `google_bigquery_table` num_bytes
* `num_long_term_bytes`: an array of `google_bigquery_table` num_long_term_bytes
* `num_rows`: an array of `google_bigquery_table` num_rows
Expand Down
6 changes: 4 additions & 2 deletions libraries/google_bigquery_dataset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'])
Expand All @@ -64,6 +62,10 @@ def exists?
!@fetched.nil?
end

def name
dataset_reference&.dataset_id
end

private

def product_url
Expand Down
2 changes: 2 additions & 0 deletions libraries/google_bigquery_tables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Tables < GcpResourceBase
filter_table_config.add(:labels, field: :labels)
filter_table_config.add(:last_modified_times, field: :last_modified_time)
filter_table_config.add(:locations, field: :location)
filter_table_config.add(:names, field: :name)
filter_table_config.add(:num_bytes, field: :num_bytes)
filter_table_config.add(:num_long_term_bytes, field: :num_long_term_bytes)
filter_table_config.add(:num_rows, field: :num_rows)
Expand Down Expand Up @@ -88,6 +89,7 @@ def transformers
'labels' => ->(obj) { return :labels, obj['labels'] },
'lastModifiedTime' => ->(obj) { return :last_modified_time, obj['lastModifiedTime'] },
'location' => ->(obj) { return :location, obj['location'] },
'name' => ->(obj) { return :name, obj['name'] },
'numBytes' => ->(obj) { return :num_bytes, obj['numBytes'] },
'numLongTermBytes' => ->(obj) { return :num_long_term_bytes, obj['numLongTermBytes'] },
'numRows' => ->(obj) { return :num_rows, obj['numRows'] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 42ad8e8

Please sign in to comment.