Module: Pangea::Testing::Assertions
- Defined in:
- lib/pangea/testing/assertions.rb
Instance Method Summary collapse
- #assert_resource_reference(ref, expected_type, expected_name, expected_outputs = {}) ⇒ Object
- #assert_tags_present(config, expected_tags) ⇒ Object
- #assert_terraform_structure(result, resource_type, resource_name) ⇒ Object
Instance Method Details
#assert_resource_reference(ref, expected_type, expected_name, expected_outputs = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/pangea/testing/assertions.rb', line 32 def assert_resource_reference(ref, expected_type, expected_name, expected_outputs = {}) expect(ref).to be_a(Pangea::Resources::ResourceReference) expect(ref.type).to eq(expected_type) expect(ref.name).to eq(expected_name) expected_outputs.each do |key, value| expect(ref.outputs[key]).to eq(value) end ref end |
#assert_tags_present(config, expected_tags) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/pangea/testing/assertions.rb', line 42 def (config, ) = config['tags'] || config[:tags] expect().not_to be_nil .each do |key, value| expect([key.to_s] || [key.to_sym]).to eq(value) end end |
#assert_terraform_structure(result, resource_type, resource_name) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pangea/testing/assertions.rb', line 20 def assert_terraform_structure(result, resource_type, resource_name) expect(result).to be_a(Hash) resource_key = result.key?('resource') ? 'resource' : :resource resources = result[resource_key] expect(resources).to be_a(Hash) type_resources = resources[resource_type] || resources[resource_type.to_sym] expect(type_resources).to be_a(Hash) config = type_resources[resource_name] || type_resources[resource_name.to_sym] expect(config).to be_a(Hash) config end |