From 56090186256313d7f6d0daefa6b01c4198818f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Sat, 14 Oct 2023 02:47:05 +0200 Subject: [PATCH] Pass nil for *types.SystemContext MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nil is defined to mean the same thing; if anything, nil is the value more likely to trigger crashes. Signed-off-by: Miloslav Trmač --- storage/storage_test.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/storage/storage_test.go b/storage/storage_test.go index fd9a1e86f2..d39844115f 100644 --- a/storage/storage_test.go +++ b/storage/storage_test.go @@ -192,10 +192,6 @@ func TestParseWithGraphDriverOptions(t *testing.T) { } } -func systemContext() *types.SystemContext { - return &types.SystemContext{} -} - // makeLayerGoroutine writes to pwriter, and on success, updates uncompressedCount // before it terminates. func makeLayerGoroutine(pwriter io.Writer, uncompressedCount *int64, compression archive.Compression) error { @@ -426,7 +422,7 @@ func TestWriteRead(t *testing.T) { require.NoError(t, err) for _, manifestFmt := range manifests { - dest, err := ref.NewImageDestination(context.Background(), systemContext()) + dest, err := ref.NewImageDestination(context.Background(), nil) require.NoError(t, err) require.Equal(t, ref.StringWithinTransport(), dest.Reference().StringWithinTransport()) t.Logf("supported manifest MIME types: %v", dest.SupportedManifestMIMETypes()) @@ -464,7 +460,7 @@ func TestWriteRead(t *testing.T) { err = dest.Close() require.NoError(t, err) - img, err := ref.NewImage(context.Background(), systemContext()) + img, err := ref.NewImage(context.Background(), nil) require.NoError(t, err) imageConfigInfo := img.ConfigInfo() if imageConfigInfo.Digest != "" { @@ -480,7 +476,7 @@ func TestWriteRead(t *testing.T) { require.NoError(t, err) assert.False(t, imageInfo.Created.IsZero()) - src, err := ref.NewImageSource(context.Background(), systemContext()) + src, err := ref.NewImageSource(context.Background(), nil) require.NoError(t, err) if src.Reference().StringWithinTransport() != ref.StringWithinTransport() { // As long as it's only the addition of an ID suffix, that's okay. @@ -527,7 +523,7 @@ func TestWriteRead(t *testing.T) { require.NoError(t, err) err = img.Close() require.NoError(t, err) - err = ref.DeleteImage(context.Background(), systemContext()) + err = ref.DeleteImage(context.Background(), nil) require.NoError(t, err) } } @@ -645,7 +641,7 @@ func TestSize(t *testing.T) { createImage(t, ref, cache, []testBlob{layer1, layer2}, &config) - img, err := ref.NewImage(context.Background(), systemContext()) + img, err := ref.NewImage(context.Background(), nil) require.NoError(t, err) manifest, _, err := img.Manifest(context.Background()) require.NoError(t, err) @@ -680,9 +676,9 @@ func TestDuplicateBlob(t *testing.T) { createImage(t, ref, cache, []testBlob{layer1, layer2, layer1, layer2}, &config) - img, err := ref.NewImage(context.Background(), systemContext()) + img, err := ref.NewImage(context.Background(), nil) require.NoError(t, err) - src, err := ref.NewImageSource(context.Background(), systemContext()) + src, err := ref.NewImageSource(context.Background(), nil) require.NoError(t, err) source, ok := src.(*storageImageSource) require.True(t, ok)