Skip to content

Commit abf23a2

Browse files
author
Kevin Paulisse
committed
Add unit test for resource hash builder handling aliases
1 parent c9b36ef commit abf23a2

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

spec/octocatalog-diff/tests/catalog_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,4 +479,34 @@
479479
expect { catalog.validate_references }.to raise_error(OctocatalogDiff::Catalog::ReferenceValidationError, error_str)
480480
end
481481
end
482+
483+
describe '#build_resource_hash' do
484+
before(:each) do
485+
resource_array = [
486+
{
487+
'type' => 'Exec',
488+
'title' => 'title of the exec',
489+
'file' => '/etc/puppetlabs/code/site/manifests/init.pp',
490+
'line' => 6,
491+
'exported' => false,
492+
'parameters' => {
493+
'alias' => 'the exec',
494+
'command' => '/bin/true'
495+
}
496+
}
497+
]
498+
described_object = described_class.allocate
499+
expect(described_object).to receive(:resources).and_return(resource_array)
500+
described_object.send(:build_resource_hash)
501+
@resource_hash = described_object.instance_variable_get(:'@resource_hash')
502+
end
503+
504+
it 'should contain the entry for the titled resource' do
505+
expect(@resource_hash['Exec']['title of the exec']).to be_a_kind_of(Hash)
506+
end
507+
508+
it 'should contain the entry for the aliased resource' do
509+
expect(@resource_hash['Exec']['the exec']).to be_a_kind_of(Hash)
510+
end
511+
end
482512
end

0 commit comments

Comments
 (0)