@@ -93,7 +93,6 @@ func TestNewClient(t *testing.T) {
93
93
}
94
94
95
95
for _ , tc := range cases {
96
-
97
96
t .Run (tc .name , func (t * testing.T ) {
98
97
t .Parallel ()
99
98
@@ -389,7 +388,6 @@ func TestClient_Token(t *testing.T) {
389
388
}
390
389
391
390
for _ , tc := range cases {
392
-
393
391
t .Run (tc .name , func (t * testing.T ) {
394
392
t .Parallel ()
395
393
@@ -513,7 +511,6 @@ func TestClient_RevokeToken(t *testing.T) {
513
511
}
514
512
515
513
for _ , tc := range cases {
516
-
517
514
t .Run (tc .name , func (t * testing.T ) {
518
515
t .Parallel ()
519
516
@@ -564,13 +561,26 @@ func TestNewClient_WithProxy(t *testing.T) {
564
561
client , err := NewClient (conf )
565
562
assert .NilError (t , err )
566
563
567
- // checks that the Transport wrapped by the client with a AppsTransport handles Proxy properly
568
564
appTransport , ok := client .installationsClient .Transport .(* ghinstallation.AppsTransport )
569
- transport := appTransport .Client .(* http.Client ).Transport .(* http.Transport )
570
- assert .Assert (t , ok )
565
+ if ! ok {
566
+ t .Fatalf ("Expected *ghinstallation.AppsTransport, got %T" , client .installationsClient .Transport )
567
+ }
571
568
assert .Assert (t , appTransport != nil )
572
569
573
- req , _ := http .NewRequest ("GET" , "http://example.com" , nil )
570
+ httpClient , ok := appTransport .Client .(* http.Client )
571
+ if ! ok {
572
+ t .Fatalf ("Expected *http.Client, got %T" , appTransport .Client )
573
+ }
574
+
575
+ // Safely assert that httpClient.Transport is of the correct type
576
+ transport , ok := httpClient .Transport .(* http.Transport )
577
+ if ! ok {
578
+ t .Fatalf ("Expected *http.Transport, got %T" , httpClient .Transport )
579
+ }
580
+
581
+ req , err := http .NewRequest ("GET" , "http://example.com" , nil )
582
+ assert .NilError (t , err )
583
+
574
584
proxy , err := transport .Proxy (req )
575
585
assert .NilError (t , err )
576
586
assert .Equal (t , proxy .String (), proxyURL )
0 commit comments