|
548 | 548 | end.to raise_error(ArgumentError, /--hiera-path is not supported in this situation/)
|
549 | 549 | end
|
550 | 550 |
|
551 |
| - it 'should handle symbolized keys' do |
| 551 | + it 'should handle hiera_path with stringified keys' do |
| 552 | + options = default_options.merge( |
| 553 | + hiera_config: OctocatalogDiff::Spec.fixture_path('repos/default/config/hiera5-simple.yaml'), |
| 554 | + hiera_path: 'hieradata' |
| 555 | + ) |
| 556 | + logger, _logger_str = OctocatalogDiff::Spec.setup_logger |
| 557 | + testobj = OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger) |
| 558 | + hiera_yaml = File.join(testobj.tempdir, 'hiera.yaml') |
| 559 | + expect(File.file?(hiera_yaml)).to eq(true) |
| 560 | + hiera_cfg = YAML.load_file(hiera_yaml) |
| 561 | + expect(hiera_cfg['defaults']).to eq('datadir' => File.join(testobj.tempdir, '/environments/production/hieradata')) |
| 562 | + expect(hiera_cfg['hierarchy']).to include('name' => 'fqdn', 'path' => 'servers/%{::fqdn}.yaml') |
| 563 | + expect(hiera_cfg['hierarchy']).to include('name' => 'datacenter', 'path' => 'datacenter/%{::datacenter}.yaml') |
| 564 | + expect(hiera_cfg['hierarchy']).to include('name' => 'special', 'path' => 'special/%{::operatingsystem}.yaml') |
| 565 | + end |
| 566 | + |
| 567 | + it 'should raise error with symbolized keys due to datadir in hierarchy' do |
552 | 568 | options = default_options.merge(
|
553 | 569 | hiera_config: OctocatalogDiff::Spec.fixture_path('repos/default/config/hiera5-symbols.yaml'),
|
554 | 570 | hiera_path: 'hieradata'
|
|
558 | 574 | OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger)
|
559 | 575 | end.to raise_error(ArgumentError, /--hiera-path is not supported in this situation/)
|
560 | 576 | end
|
| 577 | + |
| 578 | + it 'should handle hiera_path with symbolized keys' do |
| 579 | + options = default_options.merge( |
| 580 | + hiera_config: OctocatalogDiff::Spec.fixture_path('repos/default/config/hiera5-symbols-simple.yaml'), |
| 581 | + hiera_path: 'hieradata' |
| 582 | + ) |
| 583 | + logger, _logger_str = OctocatalogDiff::Spec.setup_logger |
| 584 | + testobj = OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger) |
| 585 | + hiera_yaml = File.join(testobj.tempdir, 'hiera.yaml') |
| 586 | + expect(File.file?(hiera_yaml)).to eq(true) |
| 587 | + hiera_cfg = YAML.load_file(hiera_yaml) |
| 588 | + expect(hiera_cfg[:defaults]).to eq(datadir: File.join(testobj.tempdir, '/environments/production/hieradata')) |
| 589 | + expect(hiera_cfg[:hierarchy]).to include(name: 'fqdn', path: 'servers/%{::fqdn}.yaml') |
| 590 | + expect(hiera_cfg[:hierarchy]).to include(name: 'datacenter', path: 'datacenter/%{::datacenter}.yaml') |
| 591 | + expect(hiera_cfg[:hierarchy]).to include(name: 'special', path: 'special/%{::operatingsystem}.yaml') |
| 592 | + end |
561 | 593 | end
|
562 | 594 |
|
563 | 595 | context 'with hiera_path_strip specified' do
|
|
589 | 621 | hiera_yaml = File.join(testobj.tempdir, 'hiera.yaml')
|
590 | 622 | expect(File.file?(hiera_yaml)).to eq(true)
|
591 | 623 | hiera_cfg = YAML.load_file(hiera_yaml)
|
592 |
| - expect(hiera_cfg['defaults']).to eq('datadir' => File.join(testobj.tempdir, '/environments/production/hieradata')) |
593 |
| - expect(hiera_cfg['hierarchy']).to include('name' => 'fqdn', 'path' => 'servers/%{::fqdn}.yaml') |
594 |
| - expect(hiera_cfg['hierarchy']).to include('name' => 'datacenter', 'path' => 'datacenter/%{::datacenter}.yaml') |
595 |
| - expect(hiera_cfg['hierarchy']).to include('name' => 'special', |
596 |
| - 'path' => 'special/%{::operatingsystem}.yaml', |
597 |
| - 'datadir' => File.join(testobj.tempdir, '/environments/production/special')) |
| 624 | + expect(hiera_cfg[:defaults]).to eq(datadir: File.join(testobj.tempdir, '/environments/production/hieradata')) |
| 625 | + expect(hiera_cfg[:hierarchy]).to include(name: 'fqdn', path: 'servers/%{::fqdn}.yaml') |
| 626 | + expect(hiera_cfg[:hierarchy]).to include(name: 'datacenter', path: 'datacenter/%{::datacenter}.yaml') |
| 627 | + expect(hiera_cfg[:hierarchy]).to include(name: 'special', |
| 628 | + path: 'special/%{::operatingsystem}.yaml', |
| 629 | + datadir: File.join(testobj.tempdir, '/environments/production/special')) |
598 | 630 | end
|
599 | 631 | end
|
600 | 632 | end
|
|
0 commit comments