@@ -37,15 +37,28 @@ func TestNewTransport_ValidProxyURL(t *testing.T) {
3737 if err != nil {
3838 t .Fatalf ("Expected no error for valid proxy URL, got: %v" , err )
3939 }
40-
41- proxyTransport , ok := transport .(* Transport )
40+
41+ proxyTransport , ok := transport .(* http. Transport )
4242 if ! ok {
43- t .Fatal ("Expected transport to be of type *Transport" )
43+ t .Fatal ("Expected transport to be of type *http.Transport" )
44+ }
45+
46+ // Test that the proxy function is set correctly
47+ if proxyTransport .Proxy == nil {
48+ t .Fatal ("Expected proxy function to be set" )
4449 }
45-
50+
51+ // Test the proxy function with a sample request
52+ testURL , _ := url .Parse ("http://example.com" )
53+ req := & http.Request {URL : testURL }
54+ proxyURLResult , err := proxyTransport .Proxy (req )
55+ if err != nil {
56+ t .Fatalf ("Expected no error from proxy function, got: %v" , err )
57+ }
58+
4659 expectedURL , _ := url .Parse (proxyURL )
47- if proxyTransport . ProxyURL .String () != expectedURL .String () {
48- t .Errorf ("Expected proxy URL %s, got %s" , expectedURL .String (), proxyTransport . ProxyURL .String ())
60+ if proxyURLResult .String () != expectedURL .String () {
61+ t .Errorf ("Expected proxy URL %s, got %s" , expectedURL .String (), proxyURLResult .String ())
4962 }
5063}
5164
0 commit comments