|
51 | 51 | expect(result[:output]).to match(pattern) |
52 | 52 | end |
53 | 53 |
|
54 | | - it 'should write JSON output to a specified file' do |
| 54 | + it 'should write 1.x JSON output to a specified file' do |
55 | 55 | output_file = File.join(@tmpdir, 'octo-output.json') |
56 | 56 | argv = default_argv.concat ['-o', output_file, '--output-format', 'json'] |
57 | 57 | result = OctocatalogDiff::Integration.integration(argv: argv) |
|
63 | 63 | expect(data).to be_a_kind_of(Hash) |
64 | 64 | expect(data['header']).to eq(nil) |
65 | 65 | expect(data['diff']).to be_a_kind_of(Array) |
| 66 | + |
| 67 | + answer = { |
| 68 | + 'diff_type' => '~', |
| 69 | + 'type' => 'File', |
| 70 | + 'title' => '/usr/bin/node-waf', |
| 71 | + 'structure' => %w(parameters ensure), |
| 72 | + 'old_value' => '/usr/share/nvm/0.8.11/bin/node-waf', |
| 73 | + 'new_value' => 'link', |
| 74 | + 'old_file' => '/environments/production/modules/nodejs/manifests/init.pp', |
| 75 | + 'old_line' => 55, |
| 76 | + 'new_file' => '/environments/production/modules/nodejs/manifests/init.pp', |
| 77 | + 'new_line' => 55, |
| 78 | + 'old_location' => { 'file' => '/environments/production/modules/nodejs/manifests/init.pp', 'line' => 55 }, |
| 79 | + 'new_location' => { 'file' => '/environments/production/modules/nodejs/manifests/init.pp', 'line' => 55 } |
| 80 | + } |
| 81 | + expect(data['diff']).to include(answer) |
| 82 | + end |
| 83 | + |
| 84 | + it 'should write 0.x JSON output to a specified file' do |
| 85 | + output_file = File.join(@tmpdir, 'octo-output.json') |
| 86 | + argv = default_argv.concat ['-o', output_file, '--output-format', 'legacy_json'] |
| 87 | + result = OctocatalogDiff::Integration.integration(argv: argv) |
| 88 | + expect(result[:exitcode]).to eq(2), OctocatalogDiff::Integration.format_exception(result) |
| 89 | + expect(result[:logs]).to match(/Wrote diff to #{Regexp.escape(output_file)}/) |
| 90 | + expect(File.file?(output_file)).to eq(true) |
| 91 | + content = File.read(output_file) |
| 92 | + data = JSON.parse(content) |
| 93 | + expect(data).to be_a_kind_of(Hash) |
| 94 | + expect(data['header']).to eq(nil) |
| 95 | + expect(data['diff']).to be_a_kind_of(Array) |
| 96 | + |
| 97 | + answer = [ |
| 98 | + '!', |
| 99 | + "File\f/usr/bin/npm\fparameters\ftarget", |
| 100 | + '/usr/share/nvm/0.8.11/bin/npm', |
| 101 | + nil, |
| 102 | + { 'file' => '/environments/production/modules/nodejs/manifests/init.pp', 'line' => 46 }, |
| 103 | + { 'file' => '/environments/production/modules/nodejs/manifests/init.pp', 'line' => 46 } |
| 104 | + ] |
| 105 | + expect(data['diff']).to include(answer) |
66 | 106 | end |
67 | 107 |
|
68 | 108 | it 'should write JSON output to the screen' do |
|
0 commit comments