@@ -361,6 +361,38 @@ struct GeneratedCommands {
361
361
}
362
362
}
363
363
364
+ @available ( valkeySwift 1 . 0 , * )
365
+ @Test
366
+ func testLMOVE( ) async throws {
367
+ var logger = Logger ( label: " Valkey " )
368
+ logger. logLevel = . trace
369
+ try await withValkeyConnection ( . hostname( valkeyHostname, port: 6379 ) , logger: logger) { connection in
370
+ try await withKey ( connection: connection) { key in
371
+ try await withKey ( connection: connection) { key2 in
372
+ let rtEmpty = try await connection. lmove ( source: key, destination: key2, wherefrom: . right, whereto: . left)
373
+ #expect( rtEmpty == nil )
374
+ try await connection. lpush ( key, elements: [ " a " ] )
375
+ try await connection. lpush ( key, elements: [ " b " ] )
376
+ try await connection. lpush ( key, elements: [ " c " ] )
377
+ try await connection. lpush ( key, elements: [ " d " ] )
378
+ let list1Before = try await connection. lrange ( key, start: 0 , stop: - 1 ) . decode ( as: [ String ] . self)
379
+ #expect( list1Before == [ " d " , " c " , " b " , " a " ] )
380
+ let list2Before = try await connection. lrange ( key2, start: 0 , stop: - 1 ) . decode ( as: [ String ] . self)
381
+ #expect( list2Before == [ ] )
382
+ for expectedValue in [ " a " , " b " , " c " , " d " ] {
383
+ var rt = try #require( try await connection. lmove ( source: key, destination: key2, wherefrom: . right, whereto: . left) )
384
+ let value = rt. readString ( length: 1 )
385
+ #expect( value == expectedValue)
386
+ }
387
+ let list1After = try await connection. lrange ( key, start: 0 , stop: - 1 ) . decode ( as: [ String ] . self)
388
+ #expect( list1After == [ ] )
389
+ let list2After = try await connection. lrange ( key2, start: 0 , stop: - 1 ) . decode ( as: [ String ] . self)
390
+ #expect( list2After == [ " d " , " c " , " b " , " a " ] )
391
+ }
392
+ }
393
+ }
394
+ }
395
+
364
396
@available ( valkeySwift 1 . 0 , * )
365
397
@Test ( " Test command error is thrown " )
366
398
func testCommandError( ) async throws {
0 commit comments