From 4c5fa83566bd031dc1136a0389f346b01426f811 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 7 Aug 2022 10:44:38 +1000 Subject: [PATCH] ensure we remove temporary directory --- pkg/integration/integration.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/integration/integration.go b/pkg/integration/integration.go index ab176d121..4172f3e49 100644 --- a/pkg/integration/integration.go +++ b/pkg/integration/integration.go @@ -441,6 +441,13 @@ func generateSnapshots(actualDir string, expectedDir string) (string, string, er return "", "", err } + defer func() { + err := os.RemoveAll(expectedDirCopyDir) + if err != nil { + panic(err) + } + }() + if err := restoreSpecialPaths(expectedDirCopyDir); err != nil { return "", "", err } @@ -450,11 +457,6 @@ func generateSnapshots(actualDir string, expectedDir string) (string, string, er return "", "", err } - err = os.RemoveAll(expectedDirCopyDir) - if err != nil { - return "", "", err - } - return actual, expected, nil }