@@ -156,24 +156,19 @@ func TestNewCommandNetworkSubnetDelFamily4(t *testing.T) {
156
156
157
157
// Tests network6-subnet-del command.
158
158
func TestNewCommandNetworkSubnetDelFamily6 (t * testing.T ) {
159
- command := NewCommandNetworkSubnetDel (6 , "foo" , 123 , DHCPv6 )
160
- require .NotNil (t , command )
161
- require .JSONEq (t , `{
159
+ // The network6-subnet-del command should be returned for different families.
160
+ for family := range []int64 {6 , 1 , 0 } {
161
+ command := NewCommandNetworkSubnetDel (family , "foo" , 123 , DHCPv6 )
162
+ require .NotNil (t , command )
163
+ require .JSONEq (t , `{
162
164
"command": "network6-subnet-del",
163
165
"service": ["dhcp6"],
164
166
"arguments": {
165
167
"id": 123,
166
168
"name": "foo"
167
169
}
168
170
}` , command .Marshal ())
169
- }
170
-
171
- // Test that the function creating network4-subnet-del or network6-subnet-del
172
- // panics when the family is invalid.
173
- func TestNewCommandNetworkSubnetDelInvalidFamily (t * testing.T ) {
174
- require .Panics (t , func () {
175
- _ = NewCommandNetworkSubnetDel (0 , "foo" , 123 , DHCPv4 )
176
- })
171
+ }
177
172
}
178
173
179
174
// Tests subnet4-add command.
@@ -269,27 +264,20 @@ func TestNewCommandSubnetDelFamily4(t *testing.T) {
269
264
270
265
// Tests subnet6-del command.
271
266
func TestNewCommandSubnetDelFamily6 (t * testing.T ) {
272
- command := NewCommandSubnetDel (6 , & keaconfig.SubnetCmdsDeletedSubnet {
273
- ID : 4 ,
274
- }, "dhcp6" )
275
- require .NotNil (t , command )
276
- require .JSONEq (t , `{
267
+ // The subnet6-del command should be returned for different families.
268
+ for family := range []int64 {6 , 1 , 0 } {
269
+ command := NewCommandSubnetDel (family , & keaconfig.SubnetCmdsDeletedSubnet {
270
+ ID : 4 ,
271
+ }, "dhcp6" )
272
+ require .NotNil (t , command )
273
+ require .JSONEq (t , `{
277
274
"command": "subnet6-del",
278
275
"service": ["dhcp6"],
279
276
"arguments": {
280
277
"id": 4
281
278
}
282
279
}` , command .Marshal ())
283
- }
284
-
285
- // Test that the function returning subnet4-del or subnet6-del command
286
- // panics when the family is invalid.
287
- func TestNewCommandSubnetDelInvalidFamily (t * testing.T ) {
288
- require .Panics (t , func () {
289
- _ = NewCommandSubnetDel (123 , & keaconfig.SubnetCmdsDeletedSubnet {
290
- ID : 2 ,
291
- }, DHCPv4 )
292
- })
280
+ }
293
281
}
294
282
295
283
// Tests subnet4-update command.
0 commit comments