From f78e104054558cb490a866dae4ea09b64bae3a08 Mon Sep 17 00:00:00 2001 From: Meredith Lancaster Date: Tue, 12 Mar 2024 16:47:23 -0600 Subject: [PATCH] use testing TempDir method Signed-off-by: Meredith Lancaster --- pkg/cmd/attestation/download/download_test.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/cmd/attestation/download/download_test.go b/pkg/cmd/attestation/download/download_test.go index 79fe1f001..7146d5278 100644 --- a/pkg/cmd/attestation/download/download_test.go +++ b/pkg/cmd/attestation/download/download_test.go @@ -15,9 +15,7 @@ import ( ) func TestRunDownload(t *testing.T) { - tempDir, err := os.MkdirTemp("", "gh-attestation-test") - require.NoError(t, err) - defer os.RemoveAll(tempDir) + tempDir := t.TempDir() baseOpts := Options{ ArtifactPath: "../test/data/sigstore-js-2.1.0.tgz", @@ -30,7 +28,7 @@ func TestRunDownload(t *testing.T) { } t.Run("fetch and store attestations successfully", func(t *testing.T) { - err = RunDownload(&baseOpts) + err := RunDownload(&baseOpts) require.NoError(t, err) artifact, err := artifact.NewDigestedArtifact(baseOpts.OCIClient, baseOpts.ArtifactPath, baseOpts.DigestAlgorithm) @@ -52,7 +50,7 @@ func TestRunDownload(t *testing.T) { opts := baseOpts opts.ArtifactPath = "oci://ghcr.io/github/test" - err = RunDownload(&opts) + err := RunDownload(&opts) require.NoError(t, err) artifact, err := artifact.NewDigestedArtifact(opts.OCIClient, opts.ArtifactPath, opts.DigestAlgorithm) @@ -119,9 +117,7 @@ func TestRunDownload(t *testing.T) { } func TestCreateJSONLinesFilePath(t *testing.T) { - tempDir, err := os.MkdirTemp("", "gh-attestation-test") - require.NoError(t, err) - defer os.RemoveAll(tempDir) + tempDir := t.TempDir() t.Run("with output path", func(t *testing.T) { artifact, err := artifact.NewDigestedArtifact(oci.MockClient{}, "../test/data/sigstore-js-2.1.0.tgz", "sha512")