Skip to content

Commit 079c74c

Browse files
committed
Add integration tests for hiera 5 environment level configuration
1 parent 1de751f commit 079c74c

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
version: 5
3+
defaults:
4+
datadir: hieradata
5+
data_hash: yaml_data
6+
7+
hierarchy:
8+
- name: "Default structure data"
9+
path: "nodes/%{::fqdn}.yaml"
10+
11+
- name: "Special data"
12+
path: "%{::datacenter}.yaml"
13+
datadir: special
14+
15+
- name: "Common data"
16+
path: "common.yaml"

spec/octocatalog-diff/integration/hiera5_spec.rb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,52 @@
6868
end
6969
end
7070
end
71+
72+
context 'with hiera 5 non-global, environment specific configuration' do
73+
if ENV['PUPPET_VERSION'].start_with?('3')
74+
it 'should run but not use hiera values under puppet 3' do
75+
argv = ['-n', 'rspec-node.github.net']
76+
hash = {
77+
spec_fact_file: 'facts.yaml',
78+
spec_repo: 'hiera5',
79+
spec_catalog_old: 'catalog-empty.json'
80+
}
81+
result = OctocatalogDiff::Integration.integration(hash.merge(argv: argv))
82+
expect(result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(result)
83+
84+
to_catalog = result.to
85+
86+
param1 = { 'content' => 'hard-coded' }
87+
expect(to_catalog.resource(type: 'File', title: '/tmp/nodes')['parameters']).to eq(param1)
88+
89+
param2 = { 'content' => 'hard-coded' }
90+
expect(to_catalog.resource(type: 'File', title: '/tmp/special')['parameters']).to eq(param2)
91+
92+
param3 = { 'content' => 'hard-coded' }
93+
expect(to_catalog.resource(type: 'File', title: '/tmp/common')['parameters']).to eq(param3)
94+
end
95+
else
96+
it 'should succeed in building the catalog' do
97+
argv = ['-n', 'rspec-node.github.net']
98+
hash = {
99+
spec_fact_file: 'facts.yaml',
100+
spec_repo: 'hiera5',
101+
spec_catalog_old: 'catalog-empty.json'
102+
}
103+
result = OctocatalogDiff::Integration.integration(hash.merge(argv: argv))
104+
expect(result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(result)
105+
106+
to_catalog = result.to
107+
108+
param1 = { 'content' => 'Greets from nodes' }
109+
expect(to_catalog.resource(type: 'File', title: '/tmp/nodes')['parameters']).to eq(param1)
110+
111+
param2 = { 'content' => 'Greets from special' }
112+
expect(to_catalog.resource(type: 'File', title: '/tmp/special')['parameters']).to eq(param2)
113+
114+
param3 = { 'content' => 'Greets from common' }
115+
expect(to_catalog.resource(type: 'File', title: '/tmp/common')['parameters']).to eq(param3)
116+
end
117+
end
118+
end
71119
end

0 commit comments

Comments
 (0)