Skip to content

Commit c197aa7

Browse files
authored
Merge pull request #6687 from thaJeztah/use_subtests
opts/swarmopts: use sub-tests
2 parents 0aedba5 + ba683d8 commit c197aa7

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

opts/swarmopts/port_test.go

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,14 @@ func TestPortOptValidSimpleSyntax(t *testing.T) {
137137
},
138138
}
139139
for _, tc := range testCases {
140-
var port PortOpt
141-
assert.NilError(t, port.Set(tc.value))
142-
assert.Check(t, is.Len(port.Value(), len(tc.expected)))
143-
for _, expectedPortConfig := range tc.expected {
144-
assertContains(t, port.Value(), expectedPortConfig)
145-
}
140+
t.Run(tc.value, func(t *testing.T) {
141+
var port PortOpt
142+
assert.NilError(t, port.Set(tc.value))
143+
assert.Check(t, is.Len(port.Value(), len(tc.expected)))
144+
for _, expectedPortConfig := range tc.expected {
145+
assertContains(t, port.Value(), expectedPortConfig)
146+
}
147+
})
146148
}
147149
}
148150

@@ -228,12 +230,14 @@ func TestPortOptValidComplexSyntax(t *testing.T) {
228230
},
229231
}
230232
for _, tc := range testCases {
231-
var port PortOpt
232-
assert.NilError(t, port.Set(tc.value))
233-
assert.Check(t, is.Len(port.Value(), len(tc.expected)))
234-
for _, expectedPortConfig := range tc.expected {
235-
assertContains(t, port.Value(), expectedPortConfig)
236-
}
233+
t.Run(tc.value, func(t *testing.T) {
234+
var port PortOpt
235+
assert.NilError(t, port.Set(tc.value))
236+
assert.Check(t, is.Len(port.Value(), len(tc.expected)))
237+
for _, expectedPortConfig := range tc.expected {
238+
assertContains(t, port.Value(), expectedPortConfig)
239+
}
240+
})
237241
}
238242
}
239243

@@ -319,8 +323,10 @@ func TestPortOptInvalidSimpleSyntax(t *testing.T) {
319323
},
320324
}
321325
for _, tc := range testCases {
322-
var port PortOpt
323-
assert.Error(t, port.Set(tc.value), tc.expectedError)
326+
t.Run(tc.value, func(t *testing.T) {
327+
var port PortOpt
328+
assert.Error(t, port.Set(tc.value), tc.expectedError)
329+
})
324330
}
325331
}
326332

0 commit comments

Comments
 (0)