forked from theforeman/puppet-dhcp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhost_spec.rb
99 lines (81 loc) · 2.48 KB
/
host_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
require 'spec_helper'
describe 'dhcp::host' do
on_supported_os.each do |os, facts|
let :title do 'myhost' end
let :params do {
:ip => '10.0.0.100',
:mac => '01:02:03:04:05:06',
} end
let :facts do
facts
end
let :pre_condition do
"class { '::dhcp': interfaces => ['eth0']}"
end
let(:fragment_name) do
'dhcp.hosts+10_myhost.hosts'
end
shared_examples "a concat template" do
it { is_expected.to compile.with_all_deps }
it do
is_expected.to contain_concat__fragment(fragment_name).with_content(expected_content)
end
end
context "on #{os}" do
describe 'minimal parameters' do
let(:expected_content) do
<<~CONTENT
host myhost {
hardware ethernet 01:02:03:04:05:06;
fixed-address 10.0.0.100;
ddns-hostname "myhost";
}
CONTENT
end
it_behaves_like "a concat template"
end
describe 'comment parameter' do
let(:params) { super().merge(comment: 'a useful comment') }
let(:expected_content) do
<<~CONTENT
# a useful comment
host myhost {
hardware ethernet 01:02:03:04:05:06;
fixed-address 10.0.0.100;
ddns-hostname "myhost";
}
CONTENT
end
it_behaves_like "a concat template"
end
describe 'raw_prepend parameter' do
let(:params) { super().merge(raw_prepend: 'fixed-address6 FE80:0000:0000:0000:903A:1C1A:E802:11E4;') }
let(:expected_content) do
<<~CONTENT
host myhost {
fixed-address6 FE80:0000:0000:0000:903A:1C1A:E802:11E4;
hardware ethernet 01:02:03:04:05:06;
fixed-address 10.0.0.100;
ddns-hostname "myhost";
}
CONTENT
end
it_behaves_like "a concat template"
end
describe 'raw_append parameter' do
let(:params) { super().merge(raw_append: 'dhcp-client-identifier "spec";') }
let(:expected_content) do
<<~CONTENT
host myhost {
hardware ethernet 01:02:03:04:05:06;
fixed-address 10.0.0.100;
ddns-hostname "myhost";
dhcp-client-identifier "spec";
}
CONTENT
end
it_behaves_like "a concat template"
end
end
end
end