|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require_relative 'integration_helper' |
| 4 | + |
| 5 | +describe 'equivalent array no datatypes filter integration' do |
| 6 | + context 'with default behavior' do |
| 7 | + before(:all) do |
| 8 | + @result = OctocatalogDiff::Integration.integration( |
| 9 | + spec_catalog_old: 'filter-equivalent-array-1.json', |
| 10 | + spec_catalog_new: 'filter-equivalent-array-2.json' |
| 11 | + ) |
| 12 | + end |
| 13 | + |
| 14 | + it 'should succeed' do |
| 15 | + expect(@result[:exitcode]).not_to eq(-1), "Internal error: #{@result[:exception]}\n#{@result[:logs]}" |
| 16 | + expect(@result[:exitcode]).to eq(2), "Runtime error: #{@result[:logs]}" |
| 17 | + end |
| 18 | + |
| 19 | + it 'should not suppress equivalent-but-for-data-type arrays' do |
| 20 | + diffs = OctocatalogDiff::Spec.remove_file_and_line(@result[:diffs]) |
| 21 | + expect(diffs.size).to eq(3), diffs.inspect |
| 22 | + expect(diffs[0][1..3]).to eq(["Exec\frun-my-command 1\fparameters\freturns", '0'.inspect, 0]) |
| 23 | + expect(diffs[1][1..3]).to eq(["Exec\frun-my-command 2\fparameters\freturns", %w[0 1], [0, 1]]) |
| 24 | + expect(diffs[2][1..3]).to eq(["Exec\frun-my-command 3\fparameters\freturns", %w[0 1 2], [0, 1, 2, 3]]) |
| 25 | + end |
| 26 | + end |
| 27 | + |
| 28 | + context 'with equivalent array no datatypes filter engaged' do |
| 29 | + before(:all) do |
| 30 | + @result = OctocatalogDiff::Integration.integration( |
| 31 | + spec_catalog_old: 'filter-equivalent-array-1.json', |
| 32 | + spec_catalog_new: 'filter-equivalent-array-2.json', |
| 33 | + argv: ['--filters', 'EquivalentArrayNoDatatypes'] |
| 34 | + ) |
| 35 | + end |
| 36 | + |
| 37 | + it 'should succeed' do |
| 38 | + expect(@result[:exitcode]).not_to eq(-1), "Internal error: #{@result[:exception]}\n#{@result[:logs]}" |
| 39 | + expect(@result[:exitcode]).to eq(2), "Runtime error: #{@result[:logs]}" |
| 40 | + end |
| 41 | + |
| 42 | + it 'should suppress equivalent-but-for-data-type arrays' do |
| 43 | + diffs = OctocatalogDiff::Spec.remove_file_and_line(@result[:diffs]) |
| 44 | + expect(diffs.size).to eq(2), diffs.inspect |
| 45 | + # '0' => 0 is not suppressed because it's not an array |
| 46 | + expect(diffs[0][1..3]).to eq(["Exec\frun-my-command 1\fparameters\freturns", '0'.inspect, 0]) |
| 47 | + # %w[0 1] => [0, 1] is suppressed |
| 48 | + # %w[0 1 2] => [0, 1, 2, 3] is not suppressed because it's not equivalent |
| 49 | + expect(diffs[1][1..3]).to eq(["Exec\frun-my-command 3\fparameters\freturns", %w[0 1 2], [0, 1, 2, 3]]) |
| 50 | + end |
| 51 | + end |
| 52 | +end |
0 commit comments