Merge pull request #1460 from trheyi/main
Enhance test reliability by closing SafeWriter before buffer read
This commit is contained in:
commit
5141411ab4
1 changed files with 8 additions and 0 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue