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

Function TestManagerReuseSameEntry

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

Source from the content-addressed store, hash-verified

28}
29
30func TestManagerReuseSameEntry(t *testing.T) {
31 var created atomic.Int64
32
33 manager, err := NewReuseManager(&ReuseConfig{
34 MaxConcurrency: "1",
35 MaxConnections: "1",
36 HMaxRequestTimes: "10",
37 }, makeTestTransportFactory(&created))
38 if err != nil {
39 t.Fatal(err)
40 }
41
42 transport1 := manager.GetTransport().(*ReuseTransport)
43 id1 := transportID(transport1)
44
45 transport1.Close()
46
47 transport2 := manager.GetTransport().(*ReuseTransport)
48 id2 := transportID(transport2)
49
50 if id1 != id2 {
51 t.Fatalf("expected same transport to be reused, got %d and %d", id1, id2)
52 }
53
54 transport2.Close()
55 manager.Close()
56}
57
58func TestManagerRespectMaxConnections(t *testing.T) {
59 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