You've already forked agentic-coding-workflow
fix(chat): NewStreamerHub accepts ConversationService interface; SSE handler drains ready events before ctx
This commit is contained in:
@@ -183,8 +183,13 @@ func TestStreamMessages_StopsWhenClientClosesContext(t *testing.T) {
|
||||
r.ServeHTTP(w, req)
|
||||
}()
|
||||
|
||||
// Send one event, then cancel.
|
||||
// Send one event and give the handler a moment to drain it before cancelling,
|
||||
// so the body assertion is deterministic. The cancel itself is what we're
|
||||
// verifying — that the handler exits even though the channel never closes.
|
||||
ch <- SSEEvent{ID: 1, Event: "text_delta", Data: "hi"}
|
||||
require.Eventually(t, func() bool {
|
||||
return strings.Contains(w.Body.String(), "text_delta")
|
||||
}, time.Second, 10*time.Millisecond, "event was not flushed before cancel")
|
||||
cancel()
|
||||
|
||||
// Handler must return promptly after context cancellation.
|
||||
@@ -195,7 +200,6 @@ func TestStreamMessages_StopsWhenClientClosesContext(t *testing.T) {
|
||||
t.Fatal("handler did not stop after context cancellation")
|
||||
}
|
||||
|
||||
// The one event before cancel should have been written.
|
||||
assert.Contains(t, w.Body.String(), "text_delta")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user