From dc8368cb7043ef7397ad745bd34314d636f7e18a Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Thu, 25 Jul 2024 20:27:39 +0530 Subject: [PATCH] Using test specific method to set env. variable --- ably/realtime_client_integration_test.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ably/realtime_client_integration_test.go b/ably/realtime_client_integration_test.go index 942f6dc6..f9679834 100644 --- a/ably/realtime_client_integration_test.go +++ b/ably/realtime_client_integration_test.go @@ -10,7 +10,6 @@ import ( "net/http" "net/http/httptest" "net/url" - "os" "sync" "testing" "time" @@ -243,8 +242,8 @@ func TestRealtimeProxySupport(t *testing.T) { defer server.Close() // Set HTTP_PROXY env. variable to HTTP server url - os.Setenv("HTTP_PROXY", server.URL) - os.Setenv("HTTPS_PROXY", server.URL) + t.Setenv("HTTP_PROXY", server.URL) + time.Sleep(time.Second) // Create ably realtime client client, err := ably.NewRealtime(ably.WithTLS(false), ably.WithToken("fake:token")) @@ -255,8 +254,4 @@ func TestRealtimeProxySupport(t *testing.T) { assert.Contains(t, err.Error(), "expected handshake response status code 101 but got 500") assert.True(t, clientUsesProxyFromEnv) - - // Unset HTTP_PROXY env. variable - os.Unsetenv("HTTP_PROXY") - os.Unsetenv("HTTPS_PROXY") }