fix tests

This commit is contained in:
WeidiDeng 2026-04-21 14:55:46 +08:00
parent 6d4190f4c7
commit 44d453de3c
No known key found for this signature in database
GPG Key ID: 25F87CE1741EC7CD
2 changed files with 4 additions and 3 deletions

View File

@ -226,9 +226,6 @@ func TestResponseRecorderSwitchingProtocolsIsHijackAware(t *testing.T) {
})
rr.WriteHeader(http.StatusSwitchingProtocols)
if rr.Buffered() {
t.Fatal("101 switching protocols response should not remain buffered")
}
if rr.Status() != http.StatusSwitchingProtocols {
t.Fatalf("status = %d, want %d", rr.Status(), http.StatusSwitchingProtocols)
}
@ -246,6 +243,9 @@ func TestResponseRecorderSwitchingProtocolsIsHijackAware(t *testing.T) {
}
defer conn.Close()
if rr.Buffered() {
t.Fatal("hijacked response should not remain buffered")
}
if rr.DetachAfterHijack(true) {
t.Fatal("response recorder should report hijacked state by returning false")
}

View File

@ -173,6 +173,7 @@ func TestHandlerCleanupRetainModeClosesOnlyRemovedUpstreams(t *testing.T) {
})
ts := newTunnelState(caddy.Log(), 0)
registerDetachedTunnelStates(ts)
connA := newTrackingReadWriteCloser()
connB := newTrackingReadWriteCloser()
ts.registerConnection(connA, nil, true, upstreamA)