|
616 | 616 | expect(factobj['values']['fizz']).to eq('buzz') |
617 | 617 | expect(factobj['values']['jsontest']).to eq('foo' => 'bar') |
618 | 618 | end |
| 619 | + |
| 620 | + it 'should handle regular expressions in fact overrides' do |
| 621 | + overrides_raw = %w(/dd+/=10.30.50.70 fizz=buzz jsontest=(json){"foo":"bar"} /asdflk/=true) |
| 622 | + overrides = overrides_raw.map { |x| OctocatalogDiff::API::V1::Override.create_from_input(x) } |
| 623 | + options = { |
| 624 | + basedir: OctocatalogDiff::Spec.fixture_path('repos/default'), |
| 625 | + fact_file: OctocatalogDiff::Spec.fixture_path('facts/valid-facts.yaml'), |
| 626 | + fact_override: overrides, |
| 627 | + facts_terminus: 'yaml', |
| 628 | + node: 'rspec-node.github.net' |
| 629 | + } |
| 630 | + logger, _logger_str = OctocatalogDiff::Spec.setup_logger |
| 631 | + testobj = OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger) |
| 632 | + fact_file = File.join(testobj.tempdir, 'var/yaml/facts/rspec-node.github.net.yaml') |
| 633 | + expect(File.file?(fact_file)).to eq(true) |
| 634 | + |
| 635 | + yaml_content = File.read(fact_file).split(/\n/) |
| 636 | + expect(yaml_content[0]).to eq('--- !ruby/object:Puppet::Node::Facts') |
| 637 | + |
| 638 | + yaml_content[0] = '---' # To avoid need for puppet gem |
| 639 | + factobj = YAML.load(yaml_content.join("\n")) |
| 640 | + expect(factobj).to be_a_kind_of(Hash) |
| 641 | + expect(factobj['name']).to eq('rspec-node.github.net') |
| 642 | + expect(factobj['values']).to be_a_kind_of(Hash) |
| 643 | + expect(factobj['values']['clientcert']).to eq('rspec-node.github.net') |
| 644 | + expect(factobj['values']['ipaddress']).to eq('10.30.50.70') |
| 645 | + expect(factobj['values']['fizz']).to eq('buzz') |
| 646 | + expect(factobj['values']['jsontest']).to eq('foo' => 'bar') |
| 647 | + end |
619 | 648 | end |
620 | 649 |
|
621 | 650 | context 'with invalid options' do |
|
0 commit comments