Switch to "T.TempDir()" to avoid manual cleanup.

This commit is contained in:
Joachim Bauch 2022-04-05 12:40:26 +02:00
parent b98a00ec10
commit 9c2df744c1
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02

View file

@ -27,7 +27,6 @@ import (
"crypto/x509"
"encoding/pem"
"io/ioutil"
"os"
"testing"
"time"
@ -43,16 +42,12 @@ const (
)
func newProxyServerForTest(t *testing.T) (*ProxyServer, *rsa.PrivateKey, func()) {
tempdir, err := ioutil.TempDir("", "test")
if err != nil {
t.Fatalf("could not create temporary folder: %s", err)
}
tempdir := t.TempDir()
var server *ProxyServer
shutdown := func() {
if server != nil {
server.Stop()
}
os.RemoveAll(tempdir)
}
r := mux.NewRouter()