MCPcopy
hub / github.com/MetaCubeX/mihomo / TestManagerRotateOnReusableSecs

Function TestManagerRotateOnReusableSecs

transport/xhttp/reuse_test.go:133–161  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

131}
132
133func TestManagerRotateOnReusableSecs(t *testing.T) {
134 var created atomic.Int64
135
136 manager, err := NewReuseManager(&ReuseConfig{
137 MaxConcurrency: "1",
138 MaxConnections: "1",
139 HMaxRequestTimes: "100",
140 HMaxReusableSecs: "1",
141 }, makeTestTransportFactory(&created))
142 if err != nil {
143 t.Fatal(err)
144 }
145
146 transport1 := manager.GetTransport().(*ReuseTransport)
147 id1 := transportID(transport1)
148
149 time.Sleep(1100 * time.Millisecond)
150 transport1.Close()
151
152 transport2 := manager.GetTransport().(*ReuseTransport)
153 id2 := transportID(transport2)
154
155 if id1 == id2 {
156 t.Fatalf("expected new transport after reusable timeout, got same id %d", id1)
157 }
158
159 transport2.Close()
160 manager.Close()
161}
162
163func TestManagerRotateOnConnReuseLimit(t *testing.T) {
164 var created atomic.Int64

Callers

nothing calls this directly

Calls 7

GetTransportMethod · 0.95
CloseMethod · 0.95
NewReuseManagerFunction · 0.85
makeTestTransportFactoryFunction · 0.85
transportIDFunction · 0.85
FatalMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected