[30960] | 1 | #! /usr/bin/env ruby -S rspec
|
---|
| 2 | require 'spec_helper_acceptance'
|
---|
| 3 |
|
---|
| 4 | describe 'has_interface_with function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do
|
---|
| 5 | describe 'success' do
|
---|
| 6 | it 'has_interface_with existing ipaddress' do
|
---|
| 7 | pp = <<-EOS
|
---|
| 8 | $a = $::ipaddress
|
---|
| 9 | $o = has_interface_with('ipaddress', $a)
|
---|
| 10 | notice(inline_template('has_interface_with is <%= @o.inspect %>'))
|
---|
| 11 | EOS
|
---|
| 12 |
|
---|
| 13 | apply_manifest(pp, :catch_failures => true) do |r|
|
---|
| 14 | expect(r.stdout).to match(/has_interface_with is true/)
|
---|
| 15 | end
|
---|
| 16 | end
|
---|
| 17 | it 'has_interface_with absent ipaddress' do
|
---|
| 18 | pp = <<-EOS
|
---|
| 19 | $a = '128.0.0.1'
|
---|
| 20 | $o = has_interface_with('ipaddress', $a)
|
---|
| 21 | notice(inline_template('has_interface_with is <%= @o.inspect %>'))
|
---|
| 22 | EOS
|
---|
| 23 |
|
---|
| 24 | apply_manifest(pp, :catch_failures => true) do |r|
|
---|
| 25 | expect(r.stdout).to match(/has_interface_with is false/)
|
---|
| 26 | end
|
---|
| 27 | end
|
---|
| 28 | it 'has_interface_with existing interface' do
|
---|
| 29 | pp = <<-EOS
|
---|
| 30 | if $osfamily == 'Solaris' or $osfamily == 'Darwin' {
|
---|
| 31 | $a = 'lo0'
|
---|
| 32 | }elsif $osfamily == 'windows' {
|
---|
| 33 | $a = $::kernelmajversion ? {
|
---|
| 34 | /6\.(2|3|4)/ => 'Ethernet0',
|
---|
| 35 | /6\.(0|1)/ => 'Local_Area_Connection',
|
---|
| 36 | /5\.(1|2)/ => undef, #Broken current in facter
|
---|
| 37 | }
|
---|
| 38 | }else {
|
---|
| 39 | $a = 'lo'
|
---|
| 40 | }
|
---|
| 41 | $o = has_interface_with($a)
|
---|
| 42 | notice(inline_template('has_interface_with is <%= @o.inspect %>'))
|
---|
| 43 | EOS
|
---|
| 44 |
|
---|
| 45 | apply_manifest(pp, :catch_failures => true) do |r|
|
---|
| 46 | expect(r.stdout).to match(/has_interface_with is true/)
|
---|
| 47 | end
|
---|
| 48 | end
|
---|
| 49 | end
|
---|
| 50 | describe 'failure' do
|
---|
| 51 | it 'handles no arguments'
|
---|
| 52 | it 'handles non strings'
|
---|
| 53 | end
|
---|
| 54 | end
|
---|