Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ class StdioClientTransportErrorHandlingTest {
val stderrBuffer = Buffer()
// Empty stderr = immediate EOF

val inputBuffer = Buffer()
inputBuffer.writeString("""data: {"jsonrpc":"2.0","method":"ping","id":1}\n\n""")
val inputBuffer = createNonEmptyBuffer {
"""data: {"jsonrpc":"2.0","method":"ping","id":1}\n\n"""
}
val outputBuffer = Buffer()

transport = StdioClientTransport(
Expand All @@ -66,8 +67,9 @@ class StdioClientTransportErrorHandlingTest {

@Test
fun `should call onClose exactly once on error scenarios`() = runTest {
val stderrBuffer = Buffer()
stderrBuffer.write("FATAL: critical error\n".encodeToByteArray())
val stderrBuffer = createNonEmptyBuffer {
"FATAL: critical error\n"
}

val inputBuffer = Buffer()
val outputBuffer = Buffer()
Expand Down Expand Up @@ -149,8 +151,9 @@ class StdioClientTransportErrorHandlingTest {
fun `Send should handle exceptions`(throwable: Throwable, shouldWrap: Boolean, expectedCode: Int?) = runTest {
val sendChannel: Channel<JSONRPCMessage> = mockk(relaxed = true)

val stdin = createNonEmptyBuffer { "id: 1\ndata:\n" }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the fix

transport = StdioClientTransport(
input = Buffer(),
input = stdin,
output = Buffer(),
sendChannel = sendChannel,
)
Expand All @@ -173,4 +176,10 @@ class StdioClientTransportErrorHandlingTest {
exception shouldBeSameInstanceAs throwable
}
}

fun createNonEmptyBuffer(block: () -> String): Buffer {
val buffer = Buffer()
buffer.writeString(block())
return buffer
}
}
Loading