Skip to content

Commit 1de751f

Browse files
committed
Add integration for puppet 3 + hiera 5
1 parent 2233807 commit 1de751f

File tree

2 files changed

+45
-20
lines changed

2 files changed

+45
-20
lines changed

spec/octocatalog-diff/fixtures/repos/hiera5/modules/test/manifests/init.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class test (
2-
String $param_from_nodes = 'hard-coded',
3-
String $param_from_special = 'hard-coded',
4-
String $param_from_common = 'hard-coded'
2+
$param_from_nodes = 'hard-coded',
3+
$param_from_special = 'hard-coded',
4+
$param_from_common = 'hard-coded'
55
) {
66
file { '/tmp/nodes': content => $param_from_nodes }
77
file { '/tmp/special': content => $param_from_special }

spec/octocatalog-diff/integration/hiera5_spec.rb

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,52 @@
2020
end
2121

2222
context 'with --hiera-path-strip and per-item data directory' do
23-
it 'should succeed in building the catalog' do
24-
argv = ['-n', 'rspec-node.github.net', '--hiera-path-strip', '/var/lib/puppet']
25-
hash = {
26-
hiera_config: 'config/hiera5-global.yaml',
27-
spec_fact_file: 'facts.yaml',
28-
spec_repo: 'hiera5',
29-
spec_catalog_old: 'catalog-empty.json'
30-
}
31-
result = OctocatalogDiff::Integration.integration(hash.merge(argv: argv))
32-
expect(result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(result)
23+
if ENV['PUPPET_VERSION'].start_with?('3')
24+
it 'should run but not use hiera values under puppet 3' do
25+
argv = ['-n', 'rspec-node.github.net', '--hiera-path-strip', '/var/lib/puppet']
26+
hash = {
27+
hiera_config: 'config/hiera5-global.yaml',
28+
spec_fact_file: 'facts.yaml',
29+
spec_repo: 'hiera5',
30+
spec_catalog_old: 'catalog-empty.json'
31+
}
32+
result = OctocatalogDiff::Integration.integration(hash.merge(argv: argv))
33+
expect(result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(result)
34+
35+
to_catalog = result.to
36+
37+
param1 = { 'content' => 'hard-coded' }
38+
expect(to_catalog.resource(type: 'File', title: '/tmp/nodes')['parameters']).to eq(param1)
39+
40+
param2 = { 'content' => 'hard-coded' }
41+
expect(to_catalog.resource(type: 'File', title: '/tmp/special')['parameters']).to eq(param2)
42+
43+
param3 = { 'content' => 'hard-coded' }
44+
expect(to_catalog.resource(type: 'File', title: '/tmp/common')['parameters']).to eq(param3)
45+
end
46+
else
47+
it 'should succeed in building the catalog' do
48+
argv = ['-n', 'rspec-node.github.net', '--hiera-path-strip', '/var/lib/puppet']
49+
hash = {
50+
hiera_config: 'config/hiera5-global.yaml',
51+
spec_fact_file: 'facts.yaml',
52+
spec_repo: 'hiera5',
53+
spec_catalog_old: 'catalog-empty.json'
54+
}
55+
result = OctocatalogDiff::Integration.integration(hash.merge(argv: argv))
56+
expect(result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(result)
3357

34-
to_catalog = result.to
58+
to_catalog = result.to
3559

36-
param1 = { 'content' => 'Greets from nodes' }
37-
expect(to_catalog.resource(type: 'File', title: '/tmp/nodes')['parameters']).to eq(param1)
60+
param1 = { 'content' => 'Greets from nodes' }
61+
expect(to_catalog.resource(type: 'File', title: '/tmp/nodes')['parameters']).to eq(param1)
3862

39-
param2 = { 'content' => 'Greets from special' }
40-
expect(to_catalog.resource(type: 'File', title: '/tmp/special')['parameters']).to eq(param2)
63+
param2 = { 'content' => 'Greets from special' }
64+
expect(to_catalog.resource(type: 'File', title: '/tmp/special')['parameters']).to eq(param2)
4165

42-
param3 = { 'content' => 'Greets from common' }
43-
expect(to_catalog.resource(type: 'File', title: '/tmp/common')['parameters']).to eq(param3)
66+
param3 = { 'content' => 'Greets from common' }
67+
expect(to_catalog.resource(type: 'File', title: '/tmp/common')['parameters']).to eq(param3)
68+
end
4469
end
4570
end
4671
end

0 commit comments

Comments
 (0)