|
537 | 537 |
|
538 | 538 | context 'hiera 5' do
|
539 | 539 | context 'with hiera_path specified' do
|
540 |
| - it 'should replace hiera path in defaults and hierarchy' do |
| 540 | + it 'should raise error due to datadir in hierarchy' do |
541 | 541 | options = default_options.merge(
|
542 | 542 | hiera_config: OctocatalogDiff::Spec.fixture_path('repos/default/config/hiera5.yaml'),
|
543 | 543 | hiera_path: 'hieradata'
|
544 | 544 | )
|
545 | 545 | logger, _logger_str = OctocatalogDiff::Spec.setup_logger
|
546 |
| - testobj = OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger) |
547 |
| - hiera_yaml = File.join(testobj.tempdir, 'hiera.yaml') |
548 |
| - expect(File.file?(hiera_yaml)).to eq(true) |
549 |
| - hiera_cfg = YAML.load_file(hiera_yaml) |
550 |
| - expect(hiera_cfg['defaults']).to eq('datadir' => File.join(testobj.tempdir, '/environments/production/hieradata')) |
551 |
| - expect(hiera_cfg['hierarchy']).to include('name' => 'fqdn', 'path' => 'servers/%{::fqdn}.yaml') |
552 |
| - expect(hiera_cfg['hierarchy']).to include('name' => 'datacenter', 'path' => 'datacenter/%{::datacenter}.yaml') |
553 |
| - expect(hiera_cfg['hierarchy']).to include('name' => 'special', |
554 |
| - 'path' => 'special/%{::operatingsystem}.yaml', |
555 |
| - 'datadir' => File.join(testobj.tempdir, '/environments/production/hieradata')) |
| 546 | + expect do |
| 547 | + OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger) |
| 548 | + end.to raise_error(ArgumentError, /--hiera-path is not supported in this situation/) |
556 | 549 | end
|
557 | 550 |
|
558 | 551 | it 'should handle symbolized keys' do
|
|
561 | 554 | hiera_path: 'hieradata'
|
562 | 555 | )
|
563 | 556 | logger, _logger_str = OctocatalogDiff::Spec.setup_logger
|
564 |
| - testobj = OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger) |
565 |
| - hiera_yaml = File.join(testobj.tempdir, 'hiera.yaml') |
566 |
| - expect(File.file?(hiera_yaml)).to eq(true) |
567 |
| - hiera_cfg = YAML.load_file(hiera_yaml) |
568 |
| - expect(hiera_cfg[:defaults]).to eq(datadir: File.join(testobj.tempdir, '/environments/production/hieradata')) |
569 |
| - expect(hiera_cfg[:hierarchy]).to include(name: 'fqdn', path: 'servers/%{::fqdn}.yaml') |
570 |
| - expect(hiera_cfg[:hierarchy]).to include(name: 'datacenter', path: 'datacenter/%{::datacenter}.yaml') |
571 |
| - expect(hiera_cfg[:hierarchy]).to include(name: 'special', |
572 |
| - path: 'special/%{::operatingsystem}.yaml', |
573 |
| - datadir: File.join(testobj.tempdir, '/environments/production/hieradata')) |
| 557 | + expect do |
| 558 | + OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger) |
| 559 | + end.to raise_error(ArgumentError, /--hiera-path is not supported in this situation/) |
574 | 560 | end
|
575 | 561 | end
|
576 | 562 |
|
577 | 563 | context 'with hiera_path_strip specified' do
|
578 | 564 | it 'should replace hiera path in defaults and hierarchy' do
|
579 | 565 | options = default_options.merge(
|
580 | 566 | hiera_config: OctocatalogDiff::Spec.fixture_path('repos/default/config/hiera5.yaml'),
|
581 |
| - hiera_path: 'hieradata' |
| 567 | + hiera_path_strip: '/var/lib/puppet' |
582 | 568 | )
|
583 | 569 | logger, _logger_str = OctocatalogDiff::Spec.setup_logger
|
584 | 570 | testobj = OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger)
|
585 | 571 | hiera_yaml = File.join(testobj.tempdir, 'hiera.yaml')
|
586 | 572 | expect(File.file?(hiera_yaml)).to eq(true)
|
587 | 573 | hiera_cfg = YAML.load_file(hiera_yaml)
|
588 |
| - expect(hiera_cfg[:backends]).to eq(['yaml']) |
589 |
| - expect(hiera_cfg[:yaml]).to eq(datadir: File.join(testobj.tempdir, 'environments', 'production', 'hieradata')) |
| 574 | + expect(hiera_cfg['defaults']).to eq('datadir' => File.join(testobj.tempdir, '/environments/production/hieradata')) |
| 575 | + expect(hiera_cfg['hierarchy']).to include('name' => 'fqdn', 'path' => 'servers/%{::fqdn}.yaml') |
| 576 | + expect(hiera_cfg['hierarchy']).to include('name' => 'datacenter', 'path' => 'datacenter/%{::datacenter}.yaml') |
| 577 | + expect(hiera_cfg['hierarchy']).to include('name' => 'special', |
| 578 | + 'path' => 'special/%{::operatingsystem}.yaml', |
| 579 | + 'datadir' => File.join(testobj.tempdir, '/environments/production/special')) |
590 | 580 | end
|
591 | 581 |
|
592 | 582 | it 'should handle symbolized keys' do
|
593 | 583 | options = default_options.merge(
|
594 | 584 | hiera_config: OctocatalogDiff::Spec.fixture_path('repos/default/config/hiera5-symbols.yaml'),
|
595 |
| - hiera_path: 'hieradata' |
| 585 | + hiera_path_strip: '/var/lib/puppet' |
596 | 586 | )
|
597 | 587 | logger, _logger_str = OctocatalogDiff::Spec.setup_logger
|
598 | 588 | testobj = OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger)
|
599 | 589 | hiera_yaml = File.join(testobj.tempdir, 'hiera.yaml')
|
600 | 590 | expect(File.file?(hiera_yaml)).to eq(true)
|
601 | 591 | hiera_cfg = YAML.load_file(hiera_yaml)
|
602 |
| - expect(hiera_cfg[:backends]).to eq(['yaml']) |
603 |
| - expect(hiera_cfg[:yaml]).to eq(datadir: File.join(testobj.tempdir, 'environments', 'production', 'hieradata')) |
| 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')) |
604 | 598 | end
|
605 | 599 | end
|
606 | 600 | end
|
|
0 commit comments