From b2ebee88a5e1169cf56b086a4f5e03ef27f1336e Mon Sep 17 00:00:00 2001 From: Alan Ip Date: Wed, 11 Jan 2023 14:05:09 +0000 Subject: [PATCH] Remove zip files that were generated as a result of a test. --- internal/provider/zip_archiver_test.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/internal/provider/zip_archiver_test.go b/internal/provider/zip_archiver_test.go index fab29bda..1bab6bae 100644 --- a/internal/provider/zip_archiver_test.go +++ b/internal/provider/zip_archiver_test.go @@ -14,6 +14,7 @@ import ( func TestZipArchiver_Content(t *testing.T) { zipfilepath := "archive-content.zip" archiver := NewZipArchiver(zipfilepath) + defer os.Remove(zipfilepath) if err := archiver.ArchiveContent([]byte("This is some content"), "content.txt"); err != nil { t.Fatalf("unexpected error: %s", err) } @@ -50,13 +51,16 @@ func TestZipArchiver_FileMode(t *testing.T) { stringArray := [5]string{"0444", "0644", "0666", "0744", "0777"} for _, element := range stringArray { - archiver := NewZipArchiver(zipFilePath) - archiver.SetOutputFileMode(element) - if err := archiver.ArchiveFile(toZipPath); err != nil { - t.Fatalf("unexpected error: %s", err) - } - - ensureFileMode(t, zipFilePath, element) + func() { + archiver := NewZipArchiver(zipFilePath) + defer os.Remove(zipFilePath) + archiver.SetOutputFileMode(element) + if err := archiver.ArchiveFile(toZipPath); err != nil { + t.Fatalf("unexpected error: %s", err) + } + + ensureFileMode(t, zipFilePath, element) + }() } }