From b3cb21e13c99f2aa56c80ce313db5a7e4c2c23b8 Mon Sep 17 00:00:00 2001 From: Caleb Doxsey Date: Fri, 5 Jan 2024 12:31:22 -0700 Subject: [PATCH] core/autocert: fix flaky test (#4899) * core/autocert: fix flaky test * add comment --- internal/autocert/manager_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/autocert/manager_test.go b/internal/autocert/manager_test.go index e9372b28a..40374b103 100644 --- a/internal/autocert/manager_test.go +++ b/internal/autocert/manager_test.go @@ -18,6 +18,7 @@ import ( "net/http" "net/http/httptest" "os" + "path/filepath" "testing" "time" @@ -26,6 +27,7 @@ import ( "github.com/go-chi/chi/v5/middleware" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/google/uuid" "github.com/mholt/acmez/acme" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -215,12 +217,13 @@ func TestConfig(t *testing.T) { mockACME = newMockACME(ca, srv) - tmpdir := t.TempDir() + // avoid using t.TempDir so tests don't fail: https://github.com/pomerium/pomerium/issues/4757 + tmpdir := filepath.Join(os.TempDir(), uuid.New().String()) + _ = os.MkdirAll(tmpdir, 0o755) + defer os.RemoveAll(tmpdir) li, err := net.Listen("tcp", "127.0.0.1:0") - if !assert.NoError(t, err) { - return - } + require.NoError(t, err) addr := li.Addr().String() _ = li.Close()