Commit 8a20d66 1 parent 986461e commit 8a20d66 Copy full SHA for 8a20d66
File tree 2 files changed +22
-4
lines changed
2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -232,7 +232,8 @@ export type Redis = {
232
232
sismember ( key : string , member : string ) : Promise < number > ;
233
233
smembers ( key : string ) : Promise < string [ ] > ;
234
234
smove ( source : string , destination : string , member : string ) : Promise < number > ;
235
- spop ( key : string , count ?: number ) : Promise < string > ;
235
+ spop ( key : string ) : Promise < string > ;
236
+ spop ( key : string , count : number ) : Promise < string [ ] > ;
236
237
srandmember ( key : string , count ?: number ) : Promise < string > ;
237
238
srem ( key : string , ...members : string [ ] ) : Promise < number > ;
238
239
sunion ( ...keys : string [ ] ) : Promise < string [ ] > ;
@@ -1266,7 +1267,9 @@ class RedisImpl implements Redis {
1266
1267
}
1267
1268
}
1268
1269
1269
- spop ( ...args ) {
1270
+ spop ( key : string ) : Promise < string > ;
1271
+ spop ( key : string , count : number ) : Promise < string [ ] > ;
1272
+ spop ( ...args ) : Promise < string | string [ ] > {
1270
1273
return this . execStatusReply ( "SPOP" , ...args ) ;
1271
1274
}
1272
1275
Original file line number Diff line number Diff line change 6
6
} from "./vendor/https/deno.land/std/testing/mod.ts" ;
7
7
import {
8
8
assertEquals ,
9
- assertThrowsAsync
9
+ assertThrowsAsync ,
10
+ assertArrayContains
10
11
} from "./vendor/https/deno.land/std/testing/asserts.ts" ;
11
12
// can be substituted with env variable
12
13
const addr = {
@@ -25,7 +26,9 @@ test(async function beforeAll() {
25
26
"get" ,
26
27
"getset" ,
27
28
"del1" ,
28
- "del2"
29
+ "del2" ,
30
+ "spop" ,
31
+ "spopWithCount"
29
32
) ;
30
33
} ) ;
31
34
@@ -97,6 +100,18 @@ test(async function testDecrby() {
97
100
assertEquals ( await redis . get ( "decryby" ) , "-101" ) ;
98
101
} ) ;
99
102
103
+ test ( async function testSpop ( ) {
104
+ await redis . sadd ( "spop" , "a" ) ;
105
+ const v = await redis . spop ( "spop" ) ;
106
+ assertEquals ( v , "a" ) ;
107
+ } ) ;
108
+
109
+ test ( async function testSpopWithCount ( ) {
110
+ await redis . sadd ( "spopWithCount" , "a" , "b" ) ;
111
+ const v = await redis . spop ( "spopWithCount" , 2 ) ;
112
+ assertArrayContains ( v , [ "a" , "b" ] ) ;
113
+ } ) ;
114
+
100
115
test ( async function testConcurrent ( ) {
101
116
let promises : Promise < any > [ ] = [ ] ;
102
117
for ( const key of [ "a" , "b" , "c" ] ) {
You can’t perform that action at this time.
0 commit comments