@@ -161,6 +161,7 @@ struct ConnectionTests {
161161 try await channel. closeFuture. get ( )
162162 }
163163
164+ @Test
164165 func testPipeline( ) async throws {
165166 let channel = NIOAsyncTestingChannel ( )
166167 let logger = Logger ( label: " test " )
@@ -170,9 +171,13 @@ struct ConnectionTests {
170171 SET ( key: " foo " , value: " bar " ) ,
171172 GET ( key: " foo " )
172173 )
173- let outbound = try await channel. waitForOutboundWrite ( as: ByteBuffer . self)
174- #expect( String ( buffer: outbound) == " *3 \r \n $3 \r \n SET \r \n $3 \r \n foo \r \n $3 \r \n bar \r \n *2 \r \n $3 \r \n GET \r \n $3 \r \n foo \r \n " )
175- try await channel. writeInbound ( ByteBuffer ( string: " +OK \r \n $3 \r \n bar \r \n " ) )
174+ var outbound = try await channel. waitForOutboundWrite ( as: ByteBuffer . self)
175+ let set = RESPToken ( . command( [ " SET " , " foo " , " bar " ] ) ) . base
176+ #expect( outbound. readSlice ( length: set. readableBytes) == set)
177+ #expect( outbound == RESPToken ( . command( [ " GET " , " foo " ] ) ) . base)
178+ try await channel. writeInbound ( RESPToken ( . simpleString( " OK " ) ) . base)
179+ try await channel. writeInbound ( RESPToken ( . bulkString( " bar " ) ) . base)
180+
176181 #expect( try await results. 1 . get ( ) ? . decode ( as: String . self) == " bar " )
177182 }
178183
@@ -186,9 +191,13 @@ struct ConnectionTests {
186191 SET ( key: " foo " , value: " bar " ) ,
187192 GET ( key: " foo " )
188193 )
189- let outbound = try await channel. waitForOutboundWrite ( as: ByteBuffer . self)
190- #expect( String ( buffer: outbound) == " *3 \r \n $3 \r \n SET \r \n $3 \r \n foo \r \n $3 \r \n bar \r \n *2 \r \n $3 \r \n GET \r \n $3 \r \n foo \r \n " )
191- try await channel. writeInbound ( ByteBuffer ( string: " +OK \r \n !10 \r \n BulkError! \r \n " ) )
194+ var outbound = try await channel. waitForOutboundWrite ( as: ByteBuffer . self)
195+ let set = RESPToken ( . command( [ " SET " , " foo " , " bar " ] ) ) . base
196+ #expect( outbound. readSlice ( length: set. readableBytes) == set)
197+ #expect( outbound == RESPToken ( . command( [ " GET " , " foo " ] ) ) . base)
198+ try await channel. writeInbound ( RESPToken ( . simpleString( " OK " ) ) . base)
199+ try await channel. writeInbound ( RESPToken ( . bulkError( " BulkError! " ) ) . base)
200+
192201 let results = await asyncResults
193202 #expect( throws: ValkeyClientError ( . commandError, message: " BulkError! " ) ) { try results. 1 . get ( ) }
194203 }
0 commit comments