TestServiceUpdateResolveImageChanged: use subtests

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-07-06 14:58:40 +02:00
parent 732d8b51a8
commit fde22be3ea
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 18 additions and 16 deletions

View File

@ -87,24 +87,26 @@ func TestServiceUpdateResolveImageChanged(t *testing.T) {
ctx := context.Background()
for _, testcase := range testcases {
t.Logf("Testing image %q", testcase.image)
for _, tc := range testcases {
tc := tc
t.Run(tc.image, func(t *testing.T) {
spec := map[string]swarm.ServiceSpec{
"myservice": {
TaskTemplate: swarm.TaskSpec{
ContainerSpec: &swarm.ContainerSpec{
Image: testcase.image,
Image: tc.image,
},
},
},
}
err := deployServices(ctx, client, spec, namespace, false, ResolveImageChanged)
assert.NilError(t, err)
assert.Check(t, is.Equal(receivedOptions.QueryRegistry, testcase.expectedQueryRegistry))
assert.Check(t, is.Equal(receivedService.TaskTemplate.ContainerSpec.Image, testcase.expectedImage))
assert.Check(t, is.Equal(receivedService.TaskTemplate.ForceUpdate, testcase.expectedForceUpdate))
assert.Check(t, is.Equal(receivedOptions.QueryRegistry, tc.expectedQueryRegistry))
assert.Check(t, is.Equal(receivedService.TaskTemplate.ContainerSpec.Image, tc.expectedImage))
assert.Check(t, is.Equal(receivedService.TaskTemplate.ForceUpdate, tc.expectedForceUpdate))
receivedService = swarm.ServiceSpec{}
receivedOptions = types.ServiceUpdateOptions{}
})
}
}