mirror of
https://github.com/containerd/containerd.git
synced 2026-07-06 22:59:01 +00:00
test: prevent segfault in imageverifier test
When VeriftImage returns an error, the first return value may be set to nil (this is the case for timeouts). When that is the case, it makes no point trying to access its fields later in the test. Let's use testify/require instead of testify/assert here to ensure the test halts upon failure. Signed-off-by: Athos Ribeiro <athos.ribeiro@canonical.com>
This commit is contained in:
@@ -175,7 +175,7 @@ func TestBinDirVerifyImage(t *testing.T) {
|
||||
})
|
||||
|
||||
j, err := v.VerifyImage(ctx, "registry.example.com/image:abc", ocispec.Descriptor{})
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
assert.True(t, j.OK, "expected OK, got not OK with reason: %v", j.Reason)
|
||||
assert.Less(t, len(j.Reason), len(bins)*(outputLimitBytes+1024), "reason is: %v", j.Reason) // 1024 leaves margin for the formatting around the reason.
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user