|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require_relative 'integration_helper' |
| 4 | + |
| 5 | +require 'json' |
| 6 | + |
| 7 | +describe 'fact files by branch' do |
| 8 | + before(:all) do |
| 9 | + @result = OctocatalogDiff::Integration.integration_cli( |
| 10 | + [ |
| 11 | + '-n', 'rspec-node.github.net', |
| 12 | + '--bootstrapped-to-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'), |
| 13 | + '--bootstrapped-from-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'), |
| 14 | + '--output-format', 'json', |
| 15 | + '--fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts.yaml'), |
| 16 | + '--to-fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts-different-ip.yaml'), |
| 17 | + '--puppet-binary', OctocatalogDiff::Spec::PUPPET_BINARY, |
| 18 | + '--fact-override', 'foofoo=barbar', |
| 19 | + '-d' |
| 20 | + ] |
| 21 | + ) |
| 22 | + end |
| 23 | + |
| 24 | + it 'should exit with status 2' do |
| 25 | + expect(@result.exitcode).to eq(2), @result.stderr |
| 26 | + end |
| 27 | + |
| 28 | + it 'should contain the correct diffs' do |
| 29 | + parse_result = JSON.parse(@result.stdout)['diff'].map { |x| OctocatalogDiff::Spec.remove_file_and_line(x) } |
| 30 | + expect(parse_result.size).to eq(1) |
| 31 | + expect(parse_result).to include( |
| 32 | + 'diff_type' => '~', |
| 33 | + 'type' => 'File', |
| 34 | + 'title' => '/tmp/ipaddress', |
| 35 | + 'structure' => %w(parameters content), |
| 36 | + 'old_value' => '10.20.30.40', |
| 37 | + 'new_value' => '10.30.50.70' |
| 38 | + ) |
| 39 | + end |
| 40 | + |
| 41 | + it 'should log the correct messages' do |
| 42 | + expect(@result.stderr).to match(/Catalog for . will be built with OctocatalogDiff::Catalog::Computed/) |
| 43 | + expect(@result.stderr).to match(/Override foofoo from nil to "barbar"/) |
| 44 | + expect(@result.stderr).to match(/Diffs computed for rspec-node.github.net/) |
| 45 | + end |
| 46 | +end |
0 commit comments