|
4 | 4 |
|
5 | 5 | require 'json'
|
6 | 6 |
|
7 |
| -describe 'fact files by branch' do |
| 7 | +describe 'fact files by branch, with two fact files' do |
8 | 8 | before(:all) do
|
9 | 9 | @result = OctocatalogDiff::Integration.integration_cli(
|
10 | 10 | [
|
11 | 11 | '-n', 'rspec-node.github.net',
|
12 | 12 | '--bootstrapped-to-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'),
|
13 | 13 | '--bootstrapped-from-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'),
|
14 | 14 | '--output-format', 'json',
|
15 |
| - '--fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts.yaml'), |
| 15 | + '--from-fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts.yaml'), |
16 | 16 | '--to-fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts-different-ip.yaml'),
|
17 | 17 | '--puppet-binary', OctocatalogDiff::Spec::PUPPET_BINARY,
|
18 | 18 | '--fact-override', 'foofoo=barbar',
|
|
44 | 44 | expect(@result.stderr).to match(/Diffs computed for rspec-node.github.net/)
|
45 | 45 | end
|
46 | 46 | end
|
| 47 | + |
| 48 | +describe 'fact files by branch, with only a to fact file' do |
| 49 | + before(:all) do |
| 50 | + @tmpdir = Dir.mktmpdir |
| 51 | + ENV['PUPPET_FACT_DIR'] = @tmpdir |
| 52 | + FileUtils.cp OctocatalogDiff::Spec.fixture_path('facts/valid-facts.yaml'), File.join(@tmpdir, 'rspec-node.github.net.yaml') |
| 53 | + |
| 54 | + @result = OctocatalogDiff::Integration.integration_cli( |
| 55 | + [ |
| 56 | + '-n', 'rspec-node.github.net', |
| 57 | + '--bootstrapped-to-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'), |
| 58 | + '--bootstrapped-from-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'), |
| 59 | + '--output-format', 'json', |
| 60 | + '--to-fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts-different-ip.yaml'), |
| 61 | + '--puppet-binary', OctocatalogDiff::Spec::PUPPET_BINARY, |
| 62 | + '--fact-override', 'foofoo=barbar', |
| 63 | + '-d' |
| 64 | + ] |
| 65 | + ) |
| 66 | + end |
| 67 | + |
| 68 | + after(:all) do |
| 69 | + ENV['PUPPET_FACT_DIR'] = nil |
| 70 | + OctocatalogDiff::Spec.clean_up_tmpdir(@tmpdir) |
| 71 | + end |
| 72 | + |
| 73 | + it 'should exit with status 2' do |
| 74 | + expect(@result.exitcode).to eq(2), @result.stderr |
| 75 | + end |
| 76 | + |
| 77 | + it 'should contain the correct diffs' do |
| 78 | + parse_result = JSON.parse(@result.stdout)['diff'].map { |x| OctocatalogDiff::Spec.remove_file_and_line(x) } |
| 79 | + expect(parse_result.size).to eq(1) |
| 80 | + expect(parse_result).to include( |
| 81 | + 'diff_type' => '~', |
| 82 | + 'type' => 'File', |
| 83 | + 'title' => '/tmp/ipaddress', |
| 84 | + 'structure' => %w(parameters content), |
| 85 | + 'old_value' => '10.20.30.40', |
| 86 | + 'new_value' => '10.30.50.70' |
| 87 | + ) |
| 88 | + end |
| 89 | + |
| 90 | + it 'should log the correct messages' do |
| 91 | + expect(@result.stderr).to match(/Catalog for . will be built with OctocatalogDiff::Catalog::Computed/) |
| 92 | + expect(@result.stderr).to match(/Override foofoo from nil to "barbar"/) |
| 93 | + expect(@result.stderr).to match(/Diffs computed for rspec-node.github.net/) |
| 94 | + end |
| 95 | +end |
| 96 | + |
| 97 | +describe 'fact files by branch, with only a from fact file' do |
| 98 | + before(:all) do |
| 99 | + @tmpdir = Dir.mktmpdir |
| 100 | + ENV['PUPPET_FACT_DIR'] = @tmpdir |
| 101 | + FileUtils.cp OctocatalogDiff::Spec.fixture_path('facts/valid-facts.yaml'), File.join(@tmpdir, 'rspec-node.github.net.yaml') |
| 102 | + |
| 103 | + @result = OctocatalogDiff::Integration.integration_cli( |
| 104 | + [ |
| 105 | + '-n', 'rspec-node.github.net', |
| 106 | + '--bootstrapped-to-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'), |
| 107 | + '--bootstrapped-from-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'), |
| 108 | + '--output-format', 'json', |
| 109 | + '--from-fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts-different-ip.yaml'), |
| 110 | + '--puppet-binary', OctocatalogDiff::Spec::PUPPET_BINARY, |
| 111 | + '--fact-override', 'foofoo=barbar', |
| 112 | + '-d' |
| 113 | + ] |
| 114 | + ) |
| 115 | + end |
| 116 | + |
| 117 | + after(:all) do |
| 118 | + ENV['PUPPET_FACT_DIR'] = nil |
| 119 | + OctocatalogDiff::Spec.clean_up_tmpdir(@tmpdir) |
| 120 | + end |
| 121 | + |
| 122 | + it 'should exit with status 2' do |
| 123 | + expect(@result.exitcode).to eq(2), @result.stderr |
| 124 | + end |
| 125 | + |
| 126 | + it 'should contain the correct diffs' do |
| 127 | + parse_result = JSON.parse(@result.stdout)['diff'].map { |x| OctocatalogDiff::Spec.remove_file_and_line(x) } |
| 128 | + expect(parse_result.size).to eq(1) |
| 129 | + expect(parse_result).to include( |
| 130 | + 'diff_type' => '~', |
| 131 | + 'type' => 'File', |
| 132 | + 'title' => '/tmp/ipaddress', |
| 133 | + 'structure' => %w(parameters content), |
| 134 | + 'new_value' => '10.20.30.40', |
| 135 | + 'old_value' => '10.30.50.70' |
| 136 | + ) |
| 137 | + end |
| 138 | + |
| 139 | + it 'should log the correct messages' do |
| 140 | + expect(@result.stderr).to match(/Catalog for . will be built with OctocatalogDiff::Catalog::Computed/) |
| 141 | + expect(@result.stderr).to match(/Override foofoo from nil to "barbar"/) |
| 142 | + expect(@result.stderr).to match(/Diffs computed for rspec-node.github.net/) |
| 143 | + end |
| 144 | +end |
0 commit comments