|
6 | 6 | context 'with --hiera-path and per-item data directory' do |
7 | 7 | it 'should fail because per-item datadir is not supported with --hiera-path' do |
8 | 8 | argv = ['-n', 'rspec-node.github.net'] |
9 | | - hash = { hiera_config: 'config/hiera5-global.yaml', spec_fact_file: 'facts.yaml', spec_repo: 'hiera5' } |
| 9 | + hash = { |
| 10 | + hiera_config: 'config/hiera5-global.yaml', |
| 11 | + spec_fact_file: 'facts.yaml', |
| 12 | + spec_repo: 'hiera5', |
| 13 | + spec_catalog_old: 'catalog-empty.json' |
| 14 | + } |
10 | 15 | result = OctocatalogDiff::Integration.integration(hash.merge(argv: argv)) |
11 | 16 | expect(result.exitcode).to eq(-1), OctocatalogDiff::Integration.format_exception(result) |
12 | 17 | expect(result.exception).to be_a_kind_of(ArgumentError) |
13 | 18 | expect(result.exception.message).to match(/Hierarchy item .+ has a datadir/) |
14 | 19 | end |
15 | 20 | end |
| 21 | + |
| 22 | + 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) |
| 33 | + |
| 34 | + to_catalog = result.to |
| 35 | + |
| 36 | + param1 = { 'content' => 'Greets from nodes' } |
| 37 | + expect(to_catalog.resource(type: 'File', title: '/tmp/nodes')['parameters']).to eq(param1) |
| 38 | + |
| 39 | + param2 = { 'content' => 'Greets from special' } |
| 40 | + expect(to_catalog.resource(type: 'File', title: '/tmp/special')['parameters']).to eq(param2) |
| 41 | + |
| 42 | + param3 = { 'content' => 'Greets from common' } |
| 43 | + expect(to_catalog.resource(type: 'File', title: '/tmp/common')['parameters']).to eq(param3) |
| 44 | + end |
| 45 | + end |
16 | 46 | end |
0 commit comments