Download internal/runtime/executor/proxy_helpers_test.go from shimen/Shinwayy: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/spaces/shimen/Shinwayy/resolve/main/internal/runtime/executor/proxy_helpers_test.go
- Command line
-
hf download hf://spaces/shimen/Shinwayy/internal/runtime/executor/proxy_helpers_test.go
-
curl -L -o proxy_helpers_test.go https://huggingface.co/spaces/shimen/Shinwayy/resolve/main/internal/runtime/executor/proxy_helpers_test.go
1.41 kB
| package executor | |
| import ( | |
| "testing" | |
| "time" | |
| "github.com/router-for-me/CLIProxyAPI/v6/internal/config" | |
| ) | |
| func TestApplyTransportDefaults_FromConfig(t *testing.T) { | |
| cfg := &config.Config{} | |
| cfg.HTTPTransport.MaxIdleConns = 321 | |
| cfg.HTTPTransport.MaxIdleConnsPerHost = 33 | |
| cfg.HTTPTransport.MaxConnsPerHost = 44 | |
| cfg.HTTPTransport.IdleConnTimeoutSeconds = 17 | |
| tr := buildProxyTransport("http://127.0.0.1:8080") | |
| if tr == nil { | |
| t.Fatal("expected proxy transport") | |
| } | |
| applyTransportDefaults(tr, cfg) | |
| if tr.MaxIdleConns != 321 { | |
| t.Fatalf("MaxIdleConns=%d", tr.MaxIdleConns) | |
| } | |
| if tr.MaxIdleConnsPerHost != 33 { | |
| t.Fatalf("MaxIdleConnsPerHost=%d", tr.MaxIdleConnsPerHost) | |
| } | |
| if tr.MaxConnsPerHost != 44 { | |
| t.Fatalf("MaxConnsPerHost=%d", tr.MaxConnsPerHost) | |
| } | |
| if tr.IdleConnTimeout != 17*time.Second { | |
| t.Fatalf("IdleConnTimeout=%s", tr.IdleConnTimeout) | |
| } | |
| } | |
| func TestApplyTransportDefaults_Defaults(t *testing.T) { | |
| tr := buildProxyTransport("http://127.0.0.1:8080") | |
| if tr == nil { | |
| t.Fatal("expected proxy transport") | |
| } | |
| applyTransportDefaults(tr, nil) | |
| if tr.MaxIdleConns != 100 || tr.MaxIdleConnsPerHost != 10 { | |
| t.Fatalf("unexpected defaults: %d/%d", tr.MaxIdleConns, tr.MaxIdleConnsPerHost) | |
| } | |
| if tr.IdleConnTimeout != 90*time.Second { | |
| t.Fatalf("unexpected idle timeout: %s", tr.IdleConnTimeout) | |
| } | |
| if !tr.ForceAttemptHTTP2 { | |
| t.Fatal("ForceAttemptHTTP2 should be enabled") | |
| } | |
| } | |