diff --git a/manifests/iface.pp b/manifests/iface.pp index 006831b..7575921 100644 --- a/manifests/iface.pp +++ b/manifests/iface.pp @@ -2,21 +2,21 @@ case $family { inet: { if ! ($method in [loopback, static, manual, dhcp, bootp, ppp, wvdial]) { - fail('$method parameter must be one of loopback, static, manual, dhcp, bootp, ppp or wvdial for $family inet') + fail('method parameter must be one of loopback, static, manual, dhcp, bootp, ppp or wvdial for family inet') } } inet6: { if ! ($method in [loopback, static, manual, v4tunnel]) { - fail('$method parameter must be one of loopback, static, manual or v4tunnel for $family inet6') + fail('method parameter must be one of loopback, static, manual or v4tunnel for family inet6') } } ipx: { if ! ($method in [static, dynamic]) { - fail('$method parameter must be static or dynamic for $family ipx') + fail('method parameter must be static or dynamic for family ipx') } } default: { - fail('$family parameter must be one of inet, inet6 or ipx') + fail('family parameter must be one of inet, inet6 or ipx') } } diff --git a/spec/defines/iface_spec.rb b/spec/defines/iface_spec.rb index c239b13..ddc03c2 100644 --- a/spec/defines/iface_spec.rb +++ b/spec/defines/iface_spec.rb @@ -13,6 +13,17 @@ describe 'interfaces::iface' do let(:title) { 'eth0' } + let(:params) { { :family => 'inet', :method => 'dhcp' } } + + it { + should_not contain_interfaces__auto('eth0') + should contain_concat__fragment('interfaces::iface_eth0').with_target('/etc/network/interfaces') + should contain_concat__fragment('interfaces::iface_eth0').with_content("iface eth0 inet dhcp\n\t\n\n") + } +end + +describe 'interfaces::iface' do + let(:title) { 'eth0' } let(:params) { { :family => 'inet', :method => 'dhcp', :auto => 1 } } it { @@ -65,3 +76,47 @@ should contain_concat__fragment('interfaces::iface_eth0v6').with_content("iface eth0 inet6 static\n\taddress 2001:db8::1\n\tnetmask 64\n\n") } end + +describe 'interfaces::iface' do + let(:title) { 'eth0' } + let(:params) { { :ifname => 'eth0', :family => 'foobar', :method => 'foobar' } } + + it { + expect { + should contain_concat__fragment('interfaces::iface_eth0').with_target('/etc/network/interfaces') + }.to raise_error(Puppet::Error, /family parameter must be one of inet, inet6 or ipx/) + } +end + +describe 'interfaces::iface' do + let(:title) { 'eth0' } + let(:params) { { :ifname => 'eth0', :family => 'inet6', :method => 'foobar' } } + + it { + expect { + should contain_concat__fragment('interfaces::iface_eth0').with_target('/etc/network/interfaces') + }.to raise_error(Puppet::Error, /method parameter must be one of loopback, static, manual or v4tunnel for family inet6/) + } +end + +describe 'interfaces::iface' do + let(:title) { 'eth0' } + let(:params) { { :ifname => 'eth0', :family => 'ipx', :method => 'foobar' } } + + it { + expect { + should contain_concat__fragment('interfaces::iface_eth0').with_target('/etc/network/interfaces') + }.to raise_error(Puppet::Error, /method parameter must be static or dynamic for family ipx/) + } +end + +describe 'interfaces::iface' do + let(:title) { 'eth0' } + let(:params) { { :ifname => 'eth0', :family => 'inet', :method => 'foobar' } } + + it { + expect { + should contain_concat__fragment('interfaces::iface_eth0').with_target('/etc/network/interfaces') + }.to raise_error(Puppet::Error, /method parameter must be one of loopback, static, manual, dhcp, bootp, ppp or wvdial for family inet/) + } +end