From 5c5ef84bcb93bf9ab308501c1b02ef1d4e99a440 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 11 Mar 2026 20:42:38 +0100 Subject: [PATCH] chore: revert Windows skip tests --- .../storage/archiver_accounts_test.go | 9 ++----- .../storage/archiver_certificates_test.go | 27 ++----------------- cmd/internal/storage/archiver_compress.go | 4 +++ 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/cmd/internal/storage/archiver_accounts_test.go b/cmd/internal/storage/archiver_accounts_test.go index a12a528f4..08308ec76 100644 --- a/cmd/internal/storage/archiver_accounts_test.go +++ b/cmd/internal/storage/archiver_accounts_test.go @@ -4,7 +4,6 @@ import ( "encoding/json" "os" "path/filepath" - "runtime" "testing" "github.com/go-acme/lego/v5/cmd/internal/configuration" @@ -13,12 +12,6 @@ import ( ) func TestArchiver_Accounts(t *testing.T) { - if runtime.GOOS == "windows" { - // The error is: - // TempDir RemoveAll cleanup: unlinkat C:\Users\RUNNER~1\AppData\Local\Temp\xxx: The process cannot access the file because it is being used by another process. - t.Skip("skipping test on Windows") - } - cfg := &configuration.Configuration{ Storage: t.TempDir(), Accounts: map[string]*configuration.Account{ @@ -70,6 +63,8 @@ func generateFakeAccountFiles(t *testing.T, accountsBasePath, server, keyType, a file, err := os.Create(filename) require.NoError(t, err) + defer func() { _ = file.Close() }() + r := Account{ID: accountID} err = json.NewEncoder(file).Encode(r) diff --git a/cmd/internal/storage/archiver_certificates_test.go b/cmd/internal/storage/archiver_certificates_test.go index 83f9c9f3a..60746914e 100644 --- a/cmd/internal/storage/archiver_certificates_test.go +++ b/cmd/internal/storage/archiver_certificates_test.go @@ -5,7 +5,6 @@ import ( "os" "path/filepath" "regexp" - "runtime" "testing" "github.com/go-acme/lego/v5/certificate" @@ -15,12 +14,6 @@ import ( ) func TestArchiver_Certificates(t *testing.T) { - if runtime.GOOS == "windows" { - // The error is: - // TempDir RemoveAll cleanup: unlinkat C:\Users\RUNNER~1\AppData\Local\Temp\xxx: The process cannot access the file because it is being used by another process. - t.Skip("skipping test on Windows") - } - domain := "example.com" archiveDomain := "example.org" @@ -64,12 +57,6 @@ func TestArchiver_Certificates(t *testing.T) { } func TestArchiver_archiveCertificate(t *testing.T) { - if runtime.GOOS == "windows" { - // The error is: - // TempDir RemoveAll cleanup: unlinkat C:\Users\RUNNER~1\AppData\Local\Temp\xxx: The process cannot access the file because it is being used by another process. - t.Skip("skipping test on Windows") - } - domain := "example.com" archiver := NewArchiver(t.TempDir()) @@ -95,12 +82,6 @@ func TestArchiver_archiveCertificate(t *testing.T) { } func TestArchiver_archiveCertificate_noFileRelatedToDomain(t *testing.T) { - if runtime.GOOS == "windows" { - // The error is: - // TempDir RemoveAll cleanup: unlinkat C:\Users\RUNNER~1\AppData\Local\Temp\xxx: The process cannot access the file because it is being used by another process. - t.Skip("skipping test on Windows") - } - domain := "example.com" archiver := NewArchiver(t.TempDir()) @@ -122,12 +103,6 @@ func TestArchiver_archiveCertificate_noFileRelatedToDomain(t *testing.T) { } func TestArchiver_archiveCertificate_ambiguousDomain(t *testing.T) { - if runtime.GOOS == "windows" { - // The error is: - // TempDir RemoveAll cleanup: unlinkat C:\Users\RUNNER~1\AppData\Local\Temp\xxx: The process cannot access the file because it is being used by another process. - t.Skip("skipping test on Windows") - } - domain := "example.com" archiver := NewArchiver(t.TempDir()) @@ -191,6 +166,8 @@ func generateFakeCertificateFiles(t *testing.T, dir, domain string) []string { file, err := os.Create(filename) require.NoError(t, err) + defer func() { _ = file.Close() }() + r := certificate.Resource{ID: domain} err = json.NewEncoder(file).Encode(r) diff --git a/cmd/internal/storage/archiver_compress.go b/cmd/internal/storage/archiver_compress.go index d91d80f7c..0c921de02 100644 --- a/cmd/internal/storage/archiver_compress.go +++ b/cmd/internal/storage/archiver_compress.go @@ -13,6 +13,8 @@ func compressDirectory(name, dir, comment string) error { return err } + defer func() { _ = file.Close() }() + writer := zip.NewWriter(file) defer func() { _ = writer.Close() }() @@ -38,6 +40,8 @@ func compressFiles(dest string, files []string, comment string) error { return err } + defer func() { _ = file.Close() }() + writer := zip.NewWriter(file) defer func() { _ = writer.Close() }()