session: sends CLOSE and terminates on EOSE if query

This commit is contained in:
Jay
2026-05-17 11:45:23 -04:00
parent a6922182d6
commit 5a797c11d7
2 changed files with 44 additions and 4 deletions
+38 -4
View File
@@ -138,10 +138,44 @@ func TestRequestManager_Session(t *testing.T) {
})
t.Run("sends close on eose if query", func(t *testing.T) {
// construct a session with closeOnEOSE = true
// send a value into the eose channel
// assert the mock send was called with a CLOSE envelope for the session id
// assert terminate was called with termCloseSent
h := newMockSessionHarness()
s := newSession(
h.ctx, h.id, h.req, h.eose, h.closed, h.done,
h.send, h.terminate, true, nil)
go s.run()
// drain initial REQ send
Eventually(t, func() bool {
select {
case <-h.sent:
return true
default:
return false
}
}, "expected initial REQ send")
h.eose <- struct{}{}
var got []byte
Eventually(t, func() bool {
select {
case got = <-h.sent:
return true
default:
return false
}
}, "expected CLOSE send")
assert.Equal(t, []byte(envelope.EncloseClose(h.id)), got)
Eventually(t, func() bool {
select {
case r := <-h.terminatedWith:
return r == termCloseSent
default:
return false
}
}, "expected termCloseSent")
})
t.Run("terminates on done close", func(t *testing.T) {