From 22cd790586b24cf238c77223aa37cc23fc70f57b Mon Sep 17 00:00:00 2001 From: Eng Zer Jun Date: Sat, 27 Aug 2022 15:07:51 +0800 Subject: [PATCH] tor: replace defer cleanup with `t.Cleanup` Signed-off-by: Eng Zer Jun --- tor/cmd_info_test.go | 8 ++++---- tor/controller_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) 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{