From: David Schmitt Date: Mon, 4 Jan 2021 11:51:43 +0000 (+0000) Subject: Improve tests X-Git-Tag: v2.8.1~3^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=refs%2Fheads%2Fpdksync;p=puppet-modules%2Fpuppetlabs-firewall.git Improve tests --- diff --git a/spec/unit/puppet/type/firewall_spec.rb b/spec/unit/puppet/type/firewall_spec.rb index 5bd7895..d034b38 100755 --- a/spec/unit/puppet/type/firewall_spec.rb +++ b/spec/unit/puppet/type/firewall_spec.rb @@ -140,7 +140,7 @@ describe firewall do # rubocop:disable RSpec/MultipleDescribes describe 'source error checking' do it 'Invalid address when 256.168.2.0/24' do - expect(-> { resource[:source] = '256.168.2.0/24' }).to raise_error( + expect { resource[:source] = '256.168.2.0/24' }.to raise_error( Puppet::Error, %r{host_to_ip failed} ) end @@ -148,7 +148,7 @@ describe firewall do # rubocop:disable RSpec/MultipleDescribes describe 'destination error checking' do it 'Invalid address when 256.168.2.0/24' do - expect(-> { resource[:destination] = '256.168.2.0/24' }).to raise_error( + expect { resource[:destination] = '256.168.2.0/24' }.to raise_error( Puppet::Error, %r{host_to_ip failed} ) end @@ -156,7 +156,7 @@ describe firewall do # rubocop:disable RSpec/MultipleDescribes describe 'src_range error checking' do it 'Invalid IP when 392.168.1.1-192.168.1.10' do - expect(-> { resource[:src_range] = '392.168.1.1-192.168.1.10' }).to raise_error( + expect { resource[:src_range] = '392.168.1.1-192.168.1.10' }.to raise_error( Puppet::Error, %r{Invalid IP address} ) end @@ -164,7 +164,7 @@ describe firewall do # rubocop:disable RSpec/MultipleDescribes describe 'dst_range error checking' do it 'Invalid IP when 392.168.1.1-192.168.1.10' do - expect(-> { resource[:dst_range] = '392.168.1.1-192.168.1.10' }).to raise_error( + expect { resource[:dst_range] = '392.168.1.1-192.168.1.10' }.to raise_error( Puppet::Error, %r{Invalid IP address} ) end diff --git a/spec/unit/puppet/util/ipcidr_spec.rb b/spec/unit/puppet/util/ipcidr_spec.rb index 8551928..b57fa35 100644 --- a/spec/unit/puppet/util/ipcidr_spec.rb +++ b/spec/unit/puppet/util/ipcidr_spec.rb @@ -56,6 +56,12 @@ describe 'Puppet::Util::IPCidr' do it { expect(host.netmask).to eql '0.0.0.0' } end + describe 'ipv4 invalid address' do + subject(:host) { Puppet::Util::IPCidr.new('256.168.2.0/24') } + + it { expect { host }.to raise_error ArgumentError, %r{256.168.2.0/24} } + end + describe 'ipv6 address' do subject(:host) { ipaddr }