Update transports to send and receive data instead of strings (#42)
* Update transports to send and receive data instead of strings * Rename MockTransport helper methods * Adopt Task.sleep(for:...) instead of variant taking nanoseconds * Update comment * Revert inadvertant change to visibility of send method
This commit is contained in:
parent
de829ee648
commit
a9bcbf9ad9
1 changed files with 138 additions and 147 deletions
|
|
@ -29,7 +29,7 @@ struct StdioTransportTests {
|
|||
|
||||
// Test sending a simple message
|
||||
let message = #"{"key":"value"}"#
|
||||
try await transport.send(message)
|
||||
try await transport.send(message.data(using: .utf8)!)
|
||||
|
||||
// Read and verify the output
|
||||
var buffer = [UInt8](repeating: 0, count: 1024)
|
||||
|
|
@ -57,12 +57,12 @@ struct StdioTransportTests {
|
|||
try writer.close()
|
||||
|
||||
// Start receiving messages
|
||||
let stream: AsyncThrowingStream<String, Swift.Error> = await transport.receive()
|
||||
let stream: AsyncThrowingStream<Data, Swift.Error> = await transport.receive()
|
||||
var iterator = stream.makeAsyncIterator()
|
||||
|
||||
// Get first message
|
||||
let received = try await iterator.next()
|
||||
#expect(received == #"{"key":"value"}"#)
|
||||
#expect(received == #"{"key":"value"}"#.data(using: .utf8)!)
|
||||
|
||||
await transport.disconnect()
|
||||
}
|
||||
|
|
@ -79,7 +79,7 @@ struct StdioTransportTests {
|
|||
try writer.writeAll(invalidJSON.data(using: .utf8)!)
|
||||
try writer.close()
|
||||
|
||||
let stream: AsyncThrowingStream<String, Swift.Error> = await transport.receive()
|
||||
let stream: AsyncThrowingStream<Data, Swift.Error> = await transport.receive()
|
||||
var iterator = stream.makeAsyncIterator()
|
||||
|
||||
_ = try await iterator.next()
|
||||
|
|
|
|||
Loading…
Reference in a new issue