core/autocert: fix flaky test (#4899)

* core/autocert: fix flaky test

* add comment
This commit is contained in:
Caleb Doxsey 2024-01-05 12:31:22 -07:00 committed by GitHub
parent 915c230d8d
commit b3cb21e13c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,6 +18,7 @@ import (
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os" "os"
"path/filepath"
"testing" "testing"
"time" "time"
@ -26,6 +27,7 @@ import (
"github.com/go-chi/chi/v5/middleware" "github.com/go-chi/chi/v5/middleware"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts" "github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/mholt/acmez/acme" "github.com/mholt/acmez/acme"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -215,12 +217,13 @@ func TestConfig(t *testing.T) {
mockACME = newMockACME(ca, srv) 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") li, err := net.Listen("tcp", "127.0.0.1:0")
if !assert.NoError(t, err) { require.NoError(t, err)
return
}
addr := li.Addr().String() addr := li.Addr().String()
_ = li.Close() _ = li.Close()