|
80 | 80 | end |
81 | 81 | it 'fails when passed an IPv6 address' do |
82 | 82 | pending('Not yet implemented') |
83 | | - expect { Puppet::Type.type(:network_config).new(name: 'yay', family: :inet, ipaddress: address6) }.to raise_error |
| 83 | + expect { Puppet::Type.type(:network_config).new(name: 'yay', family: :inet, ipaddress: address6) }.to raise_error(%r{not a valid ipv4 address}) |
84 | 84 | end |
85 | 85 | end |
86 | 86 |
|
|
90 | 90 | end |
91 | 91 | it 'fails when passed an IPv4 address' do |
92 | 92 | pending('Not yet implemented') |
93 | | - expect { Puppet::Type.type(:network_config).new(name: 'yay', family: :inet6, ipaddress: address4) }.to raise_error |
| 93 | + expect { Puppet::Type.type(:network_config).new(name: 'yay', family: :inet6, ipaddress: address4) }.to raise_error(%r{not a valid ipv6 address}) |
94 | 94 | end |
95 | 95 | end |
96 | 96 |
|
97 | 97 | it 'fails if a malformed address is used' do |
98 | | - expect { Puppet::Type.type(:network_config).new(name: 'yay', ipaddress: 'This is clearly not an IP address') }.to raise_error |
| 98 | + expect { Puppet::Type.type(:network_config).new(name: 'yay', ipaddress: 'This is clearly not an IP address') }.to raise_error(%r{requires a valid ipaddress}) |
99 | 99 | end |
100 | 100 | end |
101 | 101 |
|
102 | 102 | describe 'netmask' do |
103 | 103 | it 'fails if an invalid CIDR netmask is used' do |
104 | 104 | expect do |
105 | 105 | Puppet::Type.type(:network_config).new(name: 'yay', netmask: 'This is clearly not a netmask') |
106 | | - end.to raise_error |
| 106 | + end.to raise_error(%r{requires a valid netmask}) |
107 | 107 | end |
108 | 108 | end |
109 | 109 |
|
|
167 | 167 | it 'fails if an random string is passed' do |
168 | 168 | expect do |
169 | 169 | Puppet::Type.type(:network_config).new(name: 'yay', mtu: 'This is clearly not a mtu') |
170 | | - end.to raise_error |
| 170 | + end.to raise_error(%r{must be a positive integer}) |
171 | 171 | end |
172 | 172 |
|
173 | 173 | it 'fails on values < 42' do |
174 | 174 | expect do |
175 | 175 | Puppet::Type.type(:network_config).new(name: 'yay', mtu: '41') |
176 | | - end.to raise_error |
| 176 | + end.to raise_error(%r{is not in the valid mtu range}) |
177 | 177 | end |
178 | 178 |
|
179 | 179 | it 'fails on numeric values < 42' do |
180 | 180 | expect do |
181 | 181 | Puppet::Type.type(:network_config).new(name: 'yay', mtu: 41) |
182 | | - end.to raise_error |
| 182 | + end.to raise_error(%r{is not in the valid mtu range}) |
183 | 183 | end |
184 | 184 |
|
185 | 185 | it 'fails on zero' do |
186 | 186 | expect do |
187 | 187 | Puppet::Type.type(:network_config).new(name: 'yay', mtu: '0') |
188 | | - end.to raise_error |
| 188 | + end.to raise_error(%r{is not in the valid mtu range}) |
189 | 189 | end |
190 | 190 |
|
191 | 191 | it 'fails on numeric zero' do |
192 | 192 | expect do |
193 | 193 | Puppet::Type.type(:network_config).new(name: 'yay', mtu: 0) |
194 | | - end.to raise_error |
| 194 | + end.to raise_error(%r{is not in the valid mtu range}) |
195 | 195 | end |
196 | 196 |
|
197 | 197 | it 'fails on values > 65536' do |
198 | 198 | expect do |
199 | 199 | Puppet::Type.type(:network_config).new(name: 'yay', mtu: '65537') |
200 | | - end.to raise_error |
| 200 | + end.to raise_error(%r{is not in the valid mtu range}) |
201 | 201 | end |
202 | 202 |
|
203 | 203 | it 'fails on numeric values > 65536' do |
204 | 204 | expect do |
205 | 205 | Puppet::Type.type(:network_config).new(name: 'yay', mtu: 65_537) |
206 | | - end.to raise_error |
| 206 | + end.to raise_error(%r{is not in the valid mtu range}) |
207 | 207 | end |
208 | 208 |
|
209 | 209 | it 'fails on negative values' do |
210 | 210 | expect do |
211 | 211 | Puppet::Type.type(:network_config).new(name: 'yay', mtu: '-1500') |
212 | | - end.to raise_error |
| 212 | + end.to raise_error(%r{is not a valid mtu}) |
213 | 213 | end |
214 | 214 |
|
215 | 215 | it 'fails on negative numbers' do |
216 | 216 | expect do |
217 | 217 | Puppet::Type.type(:network_config).new(name: 'yay', mtu: -1500) |
218 | | - end.to raise_error |
| 218 | + end.to raise_error(%r{is not in the valid mtu range}) |
219 | 219 | end |
220 | 220 |
|
221 | 221 | it 'fails on non-integer values' do |
222 | 222 | expect do |
223 | 223 | Puppet::Type.type(:network_config).new(name: 'yay', mtu: '1500.1') |
224 | | - end.to raise_error |
| 224 | + end.to raise_error(%r{must be a positive integer}) |
225 | 225 | end |
226 | 226 |
|
227 | 227 | it 'fails on numeric non-integer values' do |
228 | 228 | expect do |
229 | 229 | Puppet::Type.type(:network_config).new(name: 'yay', mtu: 1500.1) |
230 | | - end.to raise_error |
| 230 | + end.to raise_error(%r{must be a positive integer}) |
231 | 231 | end |
232 | 232 | end |
233 | 233 |
|
|
240 | 240 | it 'fails on undefined values' do |
241 | 241 | expect do |
242 | 242 | Puppet::Type.type(:network_config).new(name: 'yay', mode: 'foo') |
243 | | - end.to raise_error |
| 243 | + end.to raise_error(%r{Invalid value "foo". Valid values are}) |
244 | 244 | end |
245 | 245 | it 'defaults to :raw' do |
246 | 246 | expect(Puppet::Type.type(:network_config).new(name: 'yay')[:mode]).to eq(:raw) |
|
262 | 262 | it 'fails if a non-hash is passed' do |
263 | 263 | expect do |
264 | 264 | Puppet::Type.type(:network_config).new(name: 'valid', options: 'geese') |
265 | | - end.to raise_error |
| 265 | + end.to raise_error(%r{requires a hash for the 'options' parameter}) |
266 | 266 | end |
267 | 267 | end |
268 | 268 | end |
|
0 commit comments