Merge pull request #1460 from trheyi/main

Enhance test reliability by closing SafeWriter before buffer read
This commit is contained in:
Max 2026-02-11 16:41:03 +08:00 committed by GitHub
commit 5141411ab4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1276,6 +1276,11 @@ func TestJsValueSendVsSendStream(t *testing.T) {
t.Fatalf("Call failed: %v", err)
}
// Close SafeWriter to flush all pending async writes before reading buffer.
// SafeWriter processes writes in a background goroutine via channel;
// without this, the buffer may still be empty on slow CI runners.
cxt.CloseSafeWriter()
output := mockWriter.buffer.String()
assert.Contains(t, output, "message_start", "Send should emit message_start")
assert.Contains(t, output, "message_end", "Send should auto-emit message_end")
@ -1300,6 +1305,9 @@ func TestJsValueSendVsSendStream(t *testing.T) {
t.Fatalf("Call failed: %v", err)
}
// Close SafeWriter to flush all pending async writes before reading buffer.
cxt.CloseSafeWriter()
output := mockWriter.buffer.String()
assert.Contains(t, output, "message_start", "SendStream should emit message_start")
assert.NotContains(t, output, "message_end", "SendStream should NOT auto-emit message_end")