From 220ac54b732069ba3799f8d39265687d1ea9421a Mon Sep 17 00:00:00 2001 From: Yury Tsarev Date: Thu, 18 Jan 2024 09:29:27 +0100 Subject: [PATCH 1/2] Clean case directory during preparation step * Cleaning directory is crutial to avoid unexpected uptest behavior when the cases are changing between uptest run * The cases contents can change during the uptest version upgrade and when we use `--skip-delete` option * Without this change the uptest behavior is confusing the user, e.g. the `--skip-delete` option does not effectively work after the standard run because `03-delete.yaml` case is not getting removed from the case directory Signed-off-by: Yury Tsarev --- internal/prepare.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/prepare.go b/internal/prepare.go index e6614b1..e105a19 100644 --- a/internal/prepare.go +++ b/internal/prepare.go @@ -79,6 +79,9 @@ type preparer struct { func (p *preparer) prepareManifests() ([]config.Manifest, error) { caseDirectory := filepath.Join(p.testDirectory, caseDirectory) + if err := os.RemoveAll(caseDirectory); err != nil { + return nil, errors.Wrapf(err, "cannot clean directory %s", caseDirectory) + } if err := os.MkdirAll(caseDirectory, os.ModePerm); err != nil { return nil, errors.Wrapf(err, "cannot create directory %s", caseDirectory) } From 17b6df357da90e02d4e56eeea1f9ad93dd0397dc Mon Sep 17 00:00:00 2001 From: Yury Tsarev Date: Thu, 18 Jan 2024 09:58:26 +0100 Subject: [PATCH 2/2] Tame gocyclo linter Signed-off-by: Yury Tsarev --- internal/prepare.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/prepare.go b/internal/prepare.go index e105a19..a704fda 100644 --- a/internal/prepare.go +++ b/internal/prepare.go @@ -77,6 +77,7 @@ type preparer struct { testDirectory string } +//nolint:gocyclo // This function is not complex, gocyclo threshold was reached due to the error handling. func (p *preparer) prepareManifests() ([]config.Manifest, error) { caseDirectory := filepath.Join(p.testDirectory, caseDirectory) if err := os.RemoveAll(caseDirectory); err != nil {