@@ -28,7 +28,8 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
28
28
do {
29
29
var dataset : [ ( Int , Double ) ] = [ ]
30
30
for index in 1 ... 10 {
31
- dataset. append ( ( index, Double ( index) ) )
31
+ // make sure value is different from score so we can test we are getting the correct values
32
+ dataset. append ( ( index + 100 , Double ( index) ) )
32
33
}
33
34
34
35
_ = try connection. zadd ( dataset, to: SortedSetCommandsTests . testKey) . wait ( )
@@ -110,19 +111,19 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
110
111
111
112
func test_zrank( ) throws {
112
113
let futures = [
113
- connection. zrank ( of: 1 , in: key) ,
114
- connection. zrank ( of: 2 , in: key) ,
115
- connection. zrank ( of: 3 , in: key) ,
114
+ connection. zrank ( of: 101 , in: key) ,
115
+ connection. zrank ( of: 102 , in: key) ,
116
+ connection. zrank ( of: 103 , in: key) ,
116
117
]
117
118
let scores = try EventLoopFuture < Int ? > . whenAllSucceed ( futures, on: connection. eventLoop) . wait ( )
118
119
XCTAssertEqual ( scores, [ 0 , 1 , 2 ] )
119
120
}
120
121
121
122
func test_zrevrank( ) throws {
122
123
let futures = [
123
- connection. zrevrank ( of: 1 , in: key) ,
124
- connection. zrevrank ( of: 2 , in: key) ,
125
- connection. zrevrank ( of: 3 , in: key) ,
124
+ connection. zrevrank ( of: 101 , in: key) ,
125
+ connection. zrevrank ( of: 102 , in: key) ,
126
+ connection. zrevrank ( of: 103 , in: key) ,
126
127
]
127
128
let scores = try EventLoopFuture < Int ? > . whenAllSucceed ( futures, on: connection. eventLoop) . wait ( )
128
129
XCTAssertEqual ( scores, [ 9 , 8 , 7 ] )
@@ -235,21 +236,21 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
235
236
}
236
237
237
238
func test_zincrby( ) throws {
238
- var score = try connection. zincrby ( 3_00_1398.328923 , element: 1 , in: key) . wait ( )
239
+ var score = try connection. zincrby ( 3_00_1398.328923 , element: 101 , in: key) . wait ( )
239
240
XCTAssertEqual ( score, 3_001_399.328923 )
240
241
241
- score = try connection. zincrby ( - 201_309.1397318 , element: 1 , in: key) . wait ( )
242
+ score = try connection. zincrby ( - 201_309.1397318 , element: 101 , in: key) . wait ( )
242
243
XCTAssertEqual ( score, 2_800_090.1891912 )
243
244
244
- score = try connection. zincrby ( 20 , element: 1 , in: key) . wait ( )
245
+ score = try connection. zincrby ( 20 , element: 101 , in: key) . wait ( )
245
246
XCTAssertEqual ( score, 2_800_110.1891912 )
246
247
}
247
248
248
249
func test_zunionstore( ) throws {
249
250
let testKey = RedisKey ( #function + #file)
250
251
251
- _ = try connection. zadd ( [ ( 1 , 1 ) , ( 2 , 2 ) ] , to: #function) . wait ( )
252
- _ = try connection. zadd ( [ ( 3 , 3 ) , ( 4 , 4 ) ] , to: #file) . wait ( )
252
+ _ = try connection. zadd ( [ ( 101 , 1 ) , ( 102 , 2 ) ] , to: #function) . wait ( )
253
+ _ = try connection. zadd ( [ ( 103 , 3 ) , ( 104 , 4 ) ] , to: #file) . wait ( )
253
254
254
255
let unionCount = try connection. zunionstore (
255
256
as: testKey,
@@ -258,14 +259,14 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
258
259
aggregateMethod: . max
259
260
) . wait ( )
260
261
XCTAssertEqual ( unionCount, 10 )
261
- let rank = try connection. zrank ( of: 10 , in: testKey) . wait ( )
262
+ let rank = try connection. zrank ( of: 110 , in: testKey) . wait ( )
262
263
XCTAssertEqual ( rank, 9 )
263
- let score = try connection. zscore ( of: 10 , in: testKey) . wait ( )
264
+ let score = try connection. zscore ( of: 110 , in: testKey) . wait ( )
264
265
XCTAssertEqual ( score, 30 )
265
266
}
266
267
267
268
func test_zinterstore( ) throws {
268
- _ = try connection. zadd ( [ ( 3 , 3 ) , ( 10 , 10 ) , ( 11 , 11 ) ] , to: #function) . wait ( )
269
+ _ = try connection. zadd ( [ ( 103 , 3 ) , ( 110 , 10 ) , ( 111 , 11 ) ] , to: #function) . wait ( )
269
270
270
271
let unionCount = try connection. zinterstore (
271
272
as: #file,
@@ -274,9 +275,9 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
274
275
aggregateMethod: . min
275
276
) . wait ( )
276
277
XCTAssertEqual ( unionCount, 2 )
277
- let rank = try connection. zrank ( of: 10 , in: #file) . wait ( )
278
+ let rank = try connection. zrank ( of: 110 , in: #file) . wait ( )
278
279
XCTAssertEqual ( rank, 1 )
279
- let score = try connection. zscore ( of: 10 , in: #file) . wait ( )
280
+ let score = try connection. zscore ( of: 110 , in: #file) . wait ( )
280
281
XCTAssertEqual ( score, 20.0 )
281
282
}
282
283
@@ -302,9 +303,9 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
302
303
let values = try RedisConnection . _mapSortedSetResponse ( elements, scoreIsFirst: false )
303
304
. map { ( value, _) in Int ( fromRESP: value) }
304
305
305
- XCTAssertEqual ( values [ 0 ] , 2 )
306
- XCTAssertEqual ( values [ 1 ] , 3 )
307
- XCTAssertEqual ( values [ 2 ] , 4 )
306
+ XCTAssertEqual ( values [ 0 ] , 102 )
307
+ XCTAssertEqual ( values [ 1 ] , 103 )
308
+ XCTAssertEqual ( values [ 2 ] , 104 )
308
309
}
309
310
310
311
func test_zrevrange( ) throws {
@@ -330,9 +331,9 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
330
331
let values = try RedisConnection . _mapSortedSetResponse ( elements, scoreIsFirst: false )
331
332
. map { ( value, _) in Int ( fromRESP: value) }
332
333
333
- XCTAssertEqual ( values [ 0 ] , 9 )
334
- XCTAssertEqual ( values [ 1 ] , 8 )
335
- XCTAssertEqual ( values [ 2 ] , 7 )
334
+ XCTAssertEqual ( values [ 0 ] , 109 )
335
+ XCTAssertEqual ( values [ 1 ] , 108 )
336
+ XCTAssertEqual ( values [ 2 ] , 107 )
336
337
}
337
338
338
339
func test_zrangebyscore( ) throws {
@@ -459,14 +460,14 @@ final class SortedSetCommandsTests: RediStackIntegrationTestCase {
459
460
}
460
461
461
462
func test_zrem( ) throws {
462
- var count = try connection. zrem ( 1 , from: key) . wait ( )
463
+ var count = try connection. zrem ( 101 , from: key) . wait ( )
463
464
XCTAssertEqual ( count, 1 )
464
465
count = try connection. zrem ( [ 1 ] , from: key) . wait ( )
465
466
XCTAssertEqual ( count, 0 )
466
467
467
- count = try connection. zrem ( 2 , 3 , 4 , 5 , from: key) . wait ( )
468
+ count = try connection. zrem ( 102 , 103 , 104 , 105 , from: key) . wait ( )
468
469
XCTAssertEqual ( count, 4 )
469
- count = try connection. zrem ( [ 5 , 6 , 7 ] , from: key) . wait ( )
470
+ count = try connection. zrem ( [ 105 , 106 , 107 ] , from: key) . wait ( )
470
471
XCTAssertEqual ( count, 2 )
471
472
}
472
473
0 commit comments