Skip to content

Commit a7c7226

Browse files
committed
Use t.Setenv for proxy setup in tests
Signed-off-by: Martin Baillie <[email protected]>
1 parent c50f18b commit a7c7226

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

github/client_test.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"net/http"
99
"net/http/httptest"
10-
"os"
1110
"testing"
1211
"time"
1312

@@ -542,15 +541,9 @@ func TestClient_RevokeToken(t *testing.T) {
542541
}
543542

544543
func TestNewClient_WithProxy(t *testing.T) {
545-
t.Parallel()
546-
547544
proxyURL := "http://proxy.example.com:8080"
548-
os.Setenv("HTTP_PROXY", proxyURL)
549-
os.Setenv("HTTPS_PROXY", proxyURL)
550-
os.Setenv("NO_PROXY", "localhost,127.0.0.1")
551-
defer os.Unsetenv("HTTP_PROXY")
552-
defer os.Unsetenv("HTTPS_PROXY")
553-
defer os.Unsetenv("NO_PROXY")
545+
t.Setenv("HTTP_PROXY", proxyURL)
546+
t.Setenv("HTTPS_PROXY", proxyURL)
554547

555548
conf := &Config{
556549
AppID: testAppID1,
@@ -572,7 +565,6 @@ func TestNewClient_WithProxy(t *testing.T) {
572565
t.Fatalf("Expected *http.Client, got %T", appTransport.Client)
573566
}
574567

575-
// Safely assert that httpClient.Transport is of the correct type
576568
transport, ok := httpClient.Transport.(*http.Transport)
577569
if !ok {
578570
t.Fatalf("Expected *http.Transport, got %T", httpClient.Transport)

0 commit comments

Comments
 (0)