session: terminates on context cancel

This commit is contained in:
Jay
2026-05-17 11:48:17 -04:00
parent 9eca7a02d9
commit 283877619a
+25 -4
View File
@@ -197,10 +197,31 @@ func TestRequestManager_Session(t *testing.T) {
}) })
t.Run("terminates on context cancel", func(t *testing.T) { t.Run("terminates on context cancel", func(t *testing.T) {
// construct a session, hold its cancel func h := newMockSessionHarness()
// call cancel s := newSession(
// assert terminate was called with termExternal h.ctx, h.id, h.req, h.eose, h.closed, h.done,
// this covers the path that Cancel() exercises on the session h.send, h.terminate, false, nil)
go s.run()
Eventually(t, func() bool {
select {
case <-h.sent:
return true
default:
return false
}
}, "expected initial send")
s.Close()
Eventually(t, func() bool {
select {
case r := <-h.terminatedWith:
return r == termExternal
default:
return false
}
}, "expected termExternal after context cancel")
}) })
t.Run("terminates on closed signal", func(t *testing.T) { t.Run("terminates on closed signal", func(t *testing.T) {