Use t.Run for /pkg/cri tests
A majority of the tests in /pkg/cri are testing/validating multiple things per test (generally spec or options validations). This flow lends itself well to using *testing.T's Run method to run each thing as a subtest so `go test` output can actually display which subtest failed/passed. Some of the tests in the packages in pkg/cri already did this, but a bunch simply logged what sub-testcase was currently running without invoking t.Run. Signed-off-by: Daniel Canter <dcanter@microsoft.com>
This commit is contained in:
@@ -65,21 +65,22 @@ func TestSetContainerRemoving(t *testing.T) {
|
||||
expectErr: false,
|
||||
},
|
||||
} {
|
||||
t.Logf("TestCase %q", desc)
|
||||
container, err := containerstore.NewContainer(
|
||||
containerstore.Metadata{ID: testID},
|
||||
containerstore.WithFakeStatus(test.status),
|
||||
)
|
||||
assert.NoError(t, err)
|
||||
err = setContainerRemoving(container)
|
||||
if test.expectErr {
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, test.status, container.Status.Get(), "metadata should not be updated")
|
||||
} else {
|
||||
t.Run(desc, func(t *testing.T) {
|
||||
container, err := containerstore.NewContainer(
|
||||
containerstore.Metadata{ID: testID},
|
||||
containerstore.WithFakeStatus(test.status),
|
||||
)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, container.Status.Get().Removing, "removing should be set")
|
||||
assert.NoError(t, resetContainerRemoving(container))
|
||||
assert.False(t, container.Status.Get().Removing, "removing should be reset")
|
||||
}
|
||||
err = setContainerRemoving(container)
|
||||
if test.expectErr {
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, test.status, container.Status.Get(), "metadata should not be updated")
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, container.Status.Get().Removing, "removing should be set")
|
||||
assert.NoError(t, resetContainerRemoving(container))
|
||||
assert.False(t, container.Status.Get().Removing, "removing should be reset")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user