diff --git a/tor/cmd_info_test.go b/tor/cmd_info_test.go index 567c441ab..d16629cc9 100644 --- a/tor/cmd_info_test.go +++ b/tor/cmd_info_test.go @@ -25,7 +25,7 @@ func TestCheckOnionServiceSucceed(t *testing.T) { // Create mock server and client connection. proxy := createTestProxy(t) - defer proxy.cleanUp() + t.Cleanup(proxy.cleanUp) server := proxy.serverConn // Assign a fake service ID to the controller. @@ -47,7 +47,7 @@ func TestCheckOnionServiceFailOnServiceIDNotMatch(t *testing.T) { // Create mock server and client connection. proxy := createTestProxy(t) - defer proxy.cleanUp() + t.Cleanup(proxy.cleanUp) server := proxy.serverConn // Assign a fake service ID to the controller. @@ -69,7 +69,7 @@ func TestCheckOnionServiceSucceedOnMultipleServices(t *testing.T) { // Create mock server and client connection. proxy := createTestProxy(t) - defer proxy.cleanUp() + t.Cleanup(proxy.cleanUp) server := proxy.serverConn // Assign a fake service ID to the controller. @@ -92,7 +92,7 @@ func TestCheckOnionServiceFailOnClosedConnection(t *testing.T) { // Create mock server and client connection. proxy := createTestProxy(t) - defer proxy.cleanUp() + t.Cleanup(proxy.cleanUp) server := proxy.serverConn // Assign a fake service ID to the controller. diff --git a/tor/controller_test.go b/tor/controller_test.go index cfd392f58..a4bdd2b11 100644 --- a/tor/controller_test.go +++ b/tor/controller_test.go @@ -153,7 +153,7 @@ func createTestProxy(t *testing.T) *testProxy { func TestReadResponse(t *testing.T) { // Create mock server and client connection. proxy := createTestProxy(t) - defer proxy.cleanUp() + t.Cleanup(proxy.cleanUp) server := proxy.serverConn // Create a dummy tor controller. @@ -300,7 +300,7 @@ func TestReconnectTCMustBeRunning(t *testing.T) { func TestReconnectSucceed(t *testing.T) { // Create mock server and client connection. proxy := createTestProxy(t) - defer proxy.cleanUp() + t.Cleanup(proxy.cleanUp) // Create a tor controller and mark the controller as started. c := &Controller{