|
19 | 19 | end
|
20 | 20 | end
|
21 | 21 |
|
22 |
| - context 'with --hiera-path-strip and per-item data directory' do |
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 |
| 22 | + if ENV['PUPPET_VERSION'].start_with?('3') |
| 23 | + # Hiera 5 tests are not applicable |
| 24 | + else |
| 25 | + context 'with --hiera-path-strip and per-item data directory' do |
47 | 26 | it 'should succeed in building the catalog' do
|
48 | 27 | argv = ['-n', 'rspec-node.github.net', '--hiera-path-strip', '/var/lib/puppet']
|
49 | 28 | hash = {
|
|
57 | 36 |
|
58 | 37 | to_catalog = result.to
|
59 | 38 |
|
| 39 | + # Global configuration overrides environment configuration |
60 | 40 | param1 = { 'content' => 'Greets from nodes' }
|
61 | 41 | expect(to_catalog.resource(type: 'File', title: '/tmp/nodes')['parameters']).to eq(param1)
|
62 | 42 |
|
|
65 | 45 |
|
66 | 46 | param3 = { 'content' => 'Greets from common' }
|
67 | 47 | expect(to_catalog.resource(type: 'File', title: '/tmp/common')['parameters']).to eq(param3)
|
| 48 | + |
| 49 | + # Comes from environment because there is no global configuration |
| 50 | + param4 = { 'content' => 'Greets from extra-special' } |
| 51 | + expect(to_catalog.resource(type: 'File', title: '/tmp/extra-special')['parameters']).to eq(param4) |
68 | 52 | end
|
69 | 53 | end
|
70 |
| - end |
71 | 54 |
|
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 |
| 55 | + context 'with hiera 5 non-global, environment specific configuration' do |
| 56 | + it 'should succeed in building the catalog and have proper diffs' do |
75 | 57 | argv = ['-n', 'rspec-node.github.net']
|
76 | 58 | hash = {
|
77 | 59 | spec_fact_file: 'facts.yaml',
|
|
83 | 65 |
|
84 | 66 | to_catalog = result.to
|
85 | 67 |
|
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' } |
| 68 | + # All come from environment |
| 69 | + param1 = { 'content' => 'Greets from data/nodes' } |
109 | 70 | expect(to_catalog.resource(type: 'File', title: '/tmp/nodes')['parameters']).to eq(param1)
|
110 | 71 |
|
111 | 72 | param2 = { 'content' => 'Greets from special' }
|
112 | 73 | expect(to_catalog.resource(type: 'File', title: '/tmp/special')['parameters']).to eq(param2)
|
113 | 74 |
|
114 |
| - param3 = { 'content' => 'Greets from common' } |
| 75 | + param3 = { 'content' => 'Greets from data/common' } |
115 | 76 | expect(to_catalog.resource(type: 'File', title: '/tmp/common')['parameters']).to eq(param3)
|
| 77 | + |
| 78 | + param4 = { 'content' => 'Greets from extra-special' } |
| 79 | + expect(to_catalog.resource(type: 'File', title: '/tmp/extra-special')['parameters']).to eq(param4) |
116 | 80 | end
|
117 | 81 | end
|
118 | 82 | end
|
|
0 commit comments