@@ -125,29 +125,29 @@ final class KeyCommandsTests: RediStackIntegrationTestCase {
125125
126126 // TODO: #23 -- Rework Scan Unit Test
127127 // This is extremely flakey, and causes non-deterministic failures because of the assert on key counts
128- // func test_scan() throws {
129- // var dataset: [RedisKey] = .init(repeating: "", count: 10)
130- // for index in 1...15 {
131- // let key = RedisKey("key\(index)\(index % 2 == 0 ? "_even" : "_odd")")
132- // dataset.append(key)
133- // _ = try connection.set(key, to: "\(index)").wait()
134- // }
135- //
136- // var (cursor, keys) = try connection.scan (count: 5).wait()
137- // XCTAssertGreaterThanOrEqual(cursor, 0)
138- // XCTAssertGreaterThanOrEqual(keys.count, 5)
139- //
140- // (_, keys) = try connection.scan (startingFrom: cursor, count: 8).wait()
141- // XCTAssertGreaterThanOrEqual(keys.count, 8)
142- //
143- // (cursor, keys) = try connection.scan (matching: "*_odd").wait()
144- // XCTAssertGreaterThanOrEqual(cursor, 0)
145- // XCTAssertGreaterThanOrEqual(keys.count, 1)
146- // XCTAssertLessThanOrEqual(keys.count, 7)
147- //
148- // (cursor, keys) = try connection.scan (matching: "*_even*").wait()
149- // XCTAssertGreaterThanOrEqual(cursor, 0)
150- // XCTAssertGreaterThanOrEqual(keys.count, 1)
151- // XCTAssertLessThanOrEqual(keys.count, 7)
152- // }
128+ func test_scan( ) throws {
129+ var dataset : [ RedisKey ] = . init( repeating: " " , count: 10 )
130+ for index in 1 ... 15 {
131+ let key = RedisKey ( " key \( index) \( index % 2 == 0 ? " _even " : " _odd " ) " )
132+ dataset. append ( key)
133+ _ = try connection. set ( key, to: " \( index) " ) . wait ( )
134+ }
135+
136+ var ( cursor, keys) = try connection. scanKeys ( count: 5 ) . wait ( )
137+ XCTAssertGreaterThanOrEqual ( cursor, 0 )
138+ XCTAssertGreaterThanOrEqual ( keys. count, 5 )
139+
140+ ( _, keys) = try connection. scanKeys ( startingFrom: cursor, count: 8 ) . wait ( )
141+ XCTAssertGreaterThanOrEqual ( keys. count, 8 )
142+
143+ ( cursor, keys) = try connection. scanKeys ( matching: " *_odd " ) . wait ( )
144+ XCTAssertGreaterThanOrEqual ( cursor, 0 )
145+ XCTAssertGreaterThanOrEqual ( keys. count, 1 )
146+ XCTAssertLessThanOrEqual ( keys. count, 7 )
147+
148+ ( cursor, keys) = try connection. scanKeys ( matching: " *_even* " ) . wait ( )
149+ XCTAssertGreaterThanOrEqual ( cursor, 0 )
150+ XCTAssertGreaterThanOrEqual ( keys. count, 1 )
151+ XCTAssertLessThanOrEqual ( keys. count, 7 )
152+ }
153153}
0 commit comments