From fd5045c07238fa4b4416ce3f2174f2fd1f8654d3 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Wed, 22 May 2024 10:11:01 +0200 Subject: [PATCH] ci(deps): fix tenv in ".*_test.go$" Signed-off-by: Matthieu MOREL --- .golangci.yaml | 1 - pkg/dependency/parser/java/pom/artifact_test.go | 3 +-- pkg/fanal/image/daemon/podman_test.go | 2 +- pkg/iac/rego/scanner_test.go | 2 +- pkg/report/template_test.go | 3 +-- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 3df1d3809f53..09e72505b0c5 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -112,7 +112,6 @@ issues: - govet - ineffassign - misspell - - tenv - unused - linters: - gosec diff --git a/pkg/dependency/parser/java/pom/artifact_test.go b/pkg/dependency/parser/java/pom/artifact_test.go index 79715dbcca7c..8109bf4486ae 100644 --- a/pkg/dependency/parser/java/pom/artifact_test.go +++ b/pkg/dependency/parser/java/pom/artifact_test.go @@ -87,8 +87,7 @@ func Test_evaluateVariable(t *testing.T) { } envName := "TEST_GO_DEP_PARSER" - os.Setenv(envName, "1.2.3") - defer os.Unsetenv(envName) + t.Setenv(envName, "1.2.3") for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/fanal/image/daemon/podman_test.go b/pkg/fanal/image/daemon/podman_test.go index d1c0e20807b6..697895fa95e8 100644 --- a/pkg/fanal/image/daemon/podman_test.go +++ b/pkg/fanal/image/daemon/podman_test.go @@ -22,7 +22,7 @@ func setupPodmanSock(t *testing.T) *httptest.Server { runtimeDir, err := os.MkdirTemp("", "daemon") require.NoError(t, err) - os.Setenv("XDG_RUNTIME_DIR", runtimeDir) + t.Setenv("XDG_RUNTIME_DIR", runtimeDir) dir := filepath.Join(runtimeDir, "podman") err = os.MkdirAll(dir, os.ModePerm) diff --git a/pkg/iac/rego/scanner_test.go b/pkg/iac/rego/scanner_test.go index cc4bb785433a..d820fe805969 100644 --- a/pkg/iac/rego/scanner_test.go +++ b/pkg/iac/rego/scanner_test.go @@ -330,7 +330,7 @@ exception[rules] { func Test_RegoScanning_WithRuntimeValues(t *testing.T) { - _ = os.Setenv("DEFSEC_RUNTIME_VAL", "AOK") + t.Setenv("DEFSEC_RUNTIME_VAL", "AOK") srcFS := CreateFS(t, map[string]string{ "policies/test.rego": ` diff --git a/pkg/report/template_test.go b/pkg/report/template_test.go index ae1b139c8767..2dbf18167c74 100644 --- a/pkg/report/template_test.go +++ b/pkg/report/template_test.go @@ -3,7 +3,6 @@ package report_test import ( "bytes" "context" - "os" "testing" "time" @@ -168,7 +167,7 @@ func TestReportWriter_Template(t *testing.T) { t.Run(tc.name, func(t *testing.T) { ctx := clock.With(context.Background(), time.Date(2020, 8, 10, 7, 28, 17, 958601, time.UTC)) - os.Setenv("AWS_ACCOUNT_ID", "123456789012") + t.Setenv("AWS_ACCOUNT_ID", "123456789012") got := bytes.Buffer{} inputReport := types.Report{ Results: types.Results{