diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-06-21 03:36:33 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-06-23 02:22:26 +0300 |
commit | 0177ebf4b031d52a897cf785c93d4780138e075e (patch) | |
tree | 7ed9b899a3b2ff13e0e29602c7db54b3e5e71dee /test/acceptance | |
parent | 4056bf44a8c8274d817e7e8f86452c0189e55592 (diff) |
Use t.Cleanup
Diffstat (limited to 'test/acceptance')
-rw-r--r-- | test/acceptance/artifacts_test.go | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/test/acceptance/artifacts_test.go b/test/acceptance/artifacts_test.go index 476c67c1..d00ef516 100644 --- a/test/acceptance/artifacts_test.go +++ b/test/acceptance/artifacts_test.go @@ -17,10 +17,7 @@ import ( func TestArtifactProxyRequest(t *testing.T) { skipUnlessEnabled(t, "not-inplace-chroot") - transport := (TestHTTPSClient.Transport).(*http.Transport) - defer func(t time.Duration) { - transport.ResponseHeaderTimeout = t - }(transport.ResponseHeaderTimeout) + transport := (TestHTTPSClient.Transport).(*http.Transport).Clone() transport.ResponseHeaderTimeout = 5 * time.Second content := "<!DOCTYPE html><html><head><title>Title of the document</title></head><body></body></html>" @@ -49,12 +46,15 @@ func TestArtifactProxyRequest(t *testing.T) { keyFile, certFile := CreateHTTPSFixtureFiles(t) cert, err := tls.LoadX509KeyPair(certFile, keyFile) require.NoError(t, err) - defer os.Remove(keyFile) - defer os.Remove(certFile) testServer.TLS = &tls.Config{Certificates: []tls.Certificate{cert}} testServer.StartTLS() - defer testServer.Close() + + t.Cleanup(func() { + os.Remove(keyFile) + os.Remove(certFile) + testServer.Close() + }) tests := []struct { name string @@ -170,15 +170,16 @@ func TestPrivateArtifactProxyRequest(t *testing.T) { keyFile, certFile := CreateHTTPSFixtureFiles(t) cert, err := tls.LoadX509KeyPair(certFile, keyFile) require.NoError(t, err) + + testServer.TLS = &tls.Config{Certificates: []tls.Certificate{cert}} + testServer.StartTLS() + t.Cleanup(func() { os.Remove(keyFile) os.Remove(certFile) + testServer.Close() }) - testServer.TLS = &tls.Config{Certificates: []tls.Certificate{cert}} - testServer.StartTLS() - defer testServer.Close() - tests := []struct { name string host string |