Skip to content

Commit

Permalink
(TESTING)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoblitt committed Mar 1, 2023
1 parent 5582780 commit 259ddda
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 41 deletions.
27 changes: 22 additions & 5 deletions examples/connection.pp
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
nm::connection { 'test':
nm::connection { 'test1':
content => {
'connection' => {
'id' => 'test',
'type' => 'ethernet',
'interface-name' => 'test',
'id' => 'test1',
'type' => 'dummy',
'interface-name' => 'dummy1',
},
'ipv4' => {
'address1' => '10.10.10.10/24',
'method' => 'manual',
},
'ipv6' => {
'method' => 'disable',
'method' => 'ignore',
},
},
}

nm::connection { 'test2':
content => {
'connection' => {
'id' => 'test2',
'type' => 'dummy',
'interface-name' => 'dummy2',
},
'ipv4' => {
'address1' => '10.20.20.20/24',
'method' => 'manual',
},
'ipv6' => {
'method' => 'ignore',
},
},
}
6 changes: 5 additions & 1 deletion examples/connection_absent.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
nm::connection { 'test':
nm::connection { 'test1':
ensure => 'absent',
}

nm::connection { 'test2':
ensure => 'absent',
}
53 changes: 47 additions & 6 deletions spec/acceptance/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

it_behaves_like 'an idempotent resource'

describe file('/etc/NetworkManager/system-connections/test.nmconnection') do
describe file('/etc/NetworkManager/system-connections/test1.nmconnection') do
it { is_expected.to be_file }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_grouped_into 'root' }
Expand All @@ -19,27 +19,68 @@
# THIS FILE IS CONTROLLED BY PUPPET
[connection]
id=test
type=ethernet
interface-name=test
id=test1
type=dummy
interface-name=dummy1
[ipv4]
address1=10.10.10.10/24
method=manual
[ipv6]
method=disable
method=ignore
CONTENT
end
end

describe interface('dummy1') do
it { should have_ipv4_address('10.10.10.10/24') }
end

describe file('/etc/NetworkManager/system-connections/test2.nmconnection') do
it { is_expected.to be_file }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_grouped_into 'root' }
it { is_expected.to be_mode '600' } # serverspec does not like a leading 0

its(:content) do
is_expected.to match <<~CONTENT
# THIS FILE IS CONTROLLED BY PUPPET
[connection]
id=test2
type=dummy
interface-name=dummy2
[ipv4]
address1=10.20.20.20/24
method=manual
[ipv6]
method=ignore
CONTENT
end
end

describe interface('dummy2') do
it { should have_ipv4_address('10.20.20.20/24') }
end
end

context 'connection absent' do
include_examples 'the example', 'connection_absent.pp'

it_behaves_like 'an idempotent resource'

describe file('/etc/NetworkManager/system-connections/test.nmconnection') do
describe file('/etc/NetworkManager/system-connections/test1.nmconnection') do
it { is_expected.not_to exist }
end

describe interface('dummy1') do
it { is_expected.not_to exist }
end

describe file('/etc/NetworkManager/system-connections/test2.nmconnection') do
it { is_expected.not_to exist }
end
end
Expand Down
20 changes: 0 additions & 20 deletions spec/acceptance/nm_spec.rb

This file was deleted.

9 changes: 0 additions & 9 deletions spec/support/acceptance/setup.rb

This file was deleted.

0 comments on commit 259ddda

Please sign in to comment.