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

Function TestManagerRotateOnRequestLimit

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

Source from the content-addressed store, hash-verified

103}
104
105func TestManagerRotateOnRequestLimit(t *testing.T) {
106 var created atomic.Int64
107
108 manager, err := NewReuseManager(&ReuseConfig{
109 MaxConcurrency: "1",
110 MaxConnections: "1",
111 HMaxRequestTimes: "1",
112 }, makeTestTransportFactory(&created))
113 if err != nil {
114 t.Fatal(err)
115 }
116
117 transport1 := manager.GetTransport().(*ReuseTransport)
118 id1 := transportID(transport1)
119
120 transport1.Close()
121
122 transport2 := manager.GetTransport().(*ReuseTransport)
123 id2 := transportID(transport2)
124
125 if id1 == id2 {
126 t.Fatalf("expected new transport after request limit, got same id %d", id1)
127 }
128
129 transport2.Close()
130 manager.Close()
131}
132
133func TestManagerRotateOnReusableSecs(t *testing.T) {
134 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