|
2 | 2 |
|
3 | 3 | require_relative 'integration_helper' |
4 | 4 |
|
| 5 | +require 'json' |
| 6 | + |
5 | 7 | describe 'fact override integration' do |
6 | 8 | # The 'answer' to one of the tests below |
7 | 9 | let(:foofoo_params) do |
|
163 | 165 | end |
164 | 166 | end |
165 | 167 | end |
| 168 | + |
| 169 | +describe 'fact override via CLI' do |
| 170 | + before(:all) do |
| 171 | + @result = OctocatalogDiff::Integration.integration_cli( |
| 172 | + [ |
| 173 | + '-n', 'rspec-node.github.net', |
| 174 | + '--bootstrapped-to-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'), |
| 175 | + '--bootstrapped-from-dir', OctocatalogDiff::Spec.fixture_path('repos/fact-overrides'), |
| 176 | + '--to-fact-override', 'ipaddress=10.30.50.70', |
| 177 | + '--from-fact-override', 'foofoo=barbar', |
| 178 | + '--output-format', 'json', |
| 179 | + '--fact-file', OctocatalogDiff::Spec.fixture_path('facts/valid-facts.yaml'), |
| 180 | + '--puppet-binary', OctocatalogDiff::Spec::PUPPET_BINARY, |
| 181 | + '-d' |
| 182 | + ] |
| 183 | + ) |
| 184 | + end |
| 185 | + |
| 186 | + it 'should exit with status 2' do |
| 187 | + expect(@result.exitcode).to eq(2), @result.stderr |
| 188 | + end |
| 189 | + |
| 190 | + it 'should contain the correct diffs' do |
| 191 | + parse_result = JSON.parse(@result.stdout)['diff'].map { |x| OctocatalogDiff::Spec.remove_file_and_line(x) } |
| 192 | + expect(parse_result.size).to eq(2) |
| 193 | + expect(parse_result).to include( |
| 194 | + 'diff_type' => '~', |
| 195 | + 'type' => 'File', |
| 196 | + 'title' => '/tmp/ipaddress', |
| 197 | + 'structure' => %w(parameters content), |
| 198 | + 'old_value' => '10.20.30.40', |
| 199 | + 'new_value' => '10.30.50.70' |
| 200 | + ) |
| 201 | + expect(parse_result).to include( |
| 202 | + 'diff_type' => '-', |
| 203 | + 'type' => 'File', |
| 204 | + 'title' => '/tmp/foofoo', |
| 205 | + 'structure' => [], |
| 206 | + 'old_value' => { |
| 207 | + 'type' => 'File', |
| 208 | + 'title' => '/tmp/foofoo', |
| 209 | + 'tags' => %w(class default file node test), |
| 210 | + 'exported' => false, |
| 211 | + 'parameters' => { 'content' => 'barbar' } |
| 212 | + }, |
| 213 | + 'new_value' => nil |
| 214 | + ) |
| 215 | + end |
| 216 | + |
| 217 | + it 'should log the correct messages' do |
| 218 | + expect(@result.stderr).to match(/Catalog for . will be built with OctocatalogDiff::Catalog::Computed/) |
| 219 | + expect(@result.stderr).to match(/Override ipaddress from "10.20.30.40" to "10.30.50.70"/) |
| 220 | + expect(@result.stderr).to match(/Override foofoo from nil to "barbar"/) |
| 221 | + expect(@result.stderr).to match(/Diffs computed for rspec-node.github.net/) |
| 222 | + end |
| 223 | +end |
0 commit comments