|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require_relative 'integration_helper' |
| 4 | + |
| 5 | +describe 'ignore regexp integration' do |
| 6 | + before(:all) do |
| 7 | + @result = OctocatalogDiff::API::V1.catalog_diff( |
| 8 | + to_catalog: OctocatalogDiff::Spec.fixture_path('catalogs/default-catalog-changed.json'), |
| 9 | + from_catalog: OctocatalogDiff::Spec.fixture_path('catalogs/default-catalog-v4.json'), |
| 10 | + ignore: [ |
| 11 | + { |
| 12 | + type: Regexp.new('\ASsh_authorized_key\z'), |
| 13 | + attr: Regexp.new("\\Aparameters\f(foo|bar)\\z") |
| 14 | + } |
| 15 | + ] |
| 16 | + ) |
| 17 | + end |
| 18 | + |
| 19 | + it 'should succeed' do |
| 20 | + expect(@result.diffs).to be_a_kind_of(Array) |
| 21 | + end |
| 22 | + |
| 23 | + it 'should contain a non-ignored diff in another type' do |
| 24 | + lookup = { diff_type: '+', type: 'Group', title: 'bill' } |
| 25 | + expect(OctocatalogDiff::Spec.diff_match?(@result.diffs, lookup)).to eq(true), @result.diffs.inspect |
| 26 | + end |
| 27 | + |
| 28 | + it 'should contain a non-ignored removal in the same type' do |
| 29 | + lookup = { type: 'Ssh_authorized_key', title: 'root@6def27049c06f48eea8b8f37329f40799d07dc84' } |
| 30 | + expect(OctocatalogDiff::Spec.diff_match?(@result.diffs, lookup)).to eq(true), @result.diffs.inspect |
| 31 | + end |
| 32 | + |
| 33 | + it 'should contain a non-ignored diff in the same type' do |
| 34 | + lookup = { type: 'Ssh_authorized_key', title: 'bob@local', structure: %w[parameters type] } |
| 35 | + expect(OctocatalogDiff::Spec.diff_match?(@result.diffs, lookup)).to eq(true), @result.diffs.inspect |
| 36 | + end |
| 37 | + |
| 38 | + it 'should not contain an ignored diff in the same type' do |
| 39 | + lookup = { type: 'Ssh_authorized_key', title: 'bob@local', structure: %w[parameters foo] } |
| 40 | + expect(OctocatalogDiff::Spec.diff_match?(@result.diffs, lookup)).to eq(false), @result.diffs.inspect |
| 41 | + end |
| 42 | +end |
0 commit comments