diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d7404a6b83..891e261ed2 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest env: GO_VERSION: stable - GOLANGCI_LINT_VERSION: v1.62.0 + GOLANGCI_LINT_VERSION: v1.63.3 HUGO_VERSION: 0.131.0 CGO_ENABLED: 0 LEGO_E2E_TESTS: CI diff --git a/.golangci.yml b/.golangci.yml index 68fd32a682..9467cf5494 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -133,6 +133,8 @@ linters-settings: errorf: true sprintf1: true strconcat: false + usetesting: + os-setenv: false # we already have a test "framework" to handle env vars run: timeout: 10m diff --git a/challenge/dns01/dns_challenge_manual_test.go b/challenge/dns01/dns_challenge_manual_test.go index cfc728acae..26a508d1ca 100644 --- a/challenge/dns01/dns_challenge_manual_test.go +++ b/challenge/dns01/dns_challenge_manual_test.go @@ -30,9 +30,10 @@ func TestDNSProviderManual(t *testing.T) { for _, test := range testCases { t.Run(test.desc, func(t *testing.T) { - file, err := os.CreateTemp("", "lego_test") + file, err := os.CreateTemp(t.TempDir(), "lego_test") require.NoError(t, err) - defer func() { _ = os.Remove(file.Name()) }() + + t.Cleanup(func() { _ = file.Close() }) _, err = file.WriteString(test.input) require.NoError(t, err) diff --git a/platform/config/env/env_test.go b/platform/config/env/env_test.go index 4a3d0a04c4..d7c51a552b 100644 --- a/platform/config/env/env_test.go +++ b/platform/config/env/env_test.go @@ -367,9 +367,10 @@ func TestGetOrFile_ReadsFiles(t *testing.T) { err = os.Unsetenv(varEnvName) require.NoError(t, err) - file, err := os.CreateTemp("", "lego") + file, err := os.CreateTemp(t.TempDir(), "lego") require.NoError(t, err) - defer os.Remove(file.Name()) + + t.Cleanup(func() { _ = file.Close() }) err = os.WriteFile(file.Name(), []byte("lego_file\n"), 0o644) require.NoError(t, err) @@ -392,9 +393,10 @@ func TestGetOrFile_PrefersEnvVars(t *testing.T) { err = os.Unsetenv(varEnvName) require.NoError(t, err) - file, err := os.CreateTemp("", "lego") + file, err := os.CreateTemp(t.TempDir(), "lego") require.NoError(t, err) - defer os.Remove(file.Name()) + + t.Cleanup(func() { _ = file.Close() }) err = os.WriteFile(file.Name(), []byte("lego_file"), 0o644) require.NoError(t, err) diff --git a/providers/dns/designate/designate_test.go b/providers/dns/designate/designate_test.go index 881faeef1d..1045baa956 100644 --- a/providers/dns/designate/designate_test.go +++ b/providers/dns/designate/designate_test.go @@ -265,10 +265,10 @@ func TestNewDNSProviderConfig(t *testing.T) { func createCloudsYaml(t *testing.T, cloudName string, cloud clientconfig.Cloud) string { t.Helper() - file, err := os.CreateTemp("", "lego_test") + file, err := os.CreateTemp(t.TempDir(), "lego_test") require.NoError(t, err) - t.Cleanup(func() { _ = os.RemoveAll(file.Name()) }) + t.Cleanup(func() { _ = file.Close() }) clouds := clientconfig.Clouds{ Clouds: map[string]clientconfig.Cloud{