Commit 8d5f6ee 1 parent 86440c5 commit 8d5f6ee Copy full SHA for 8d5f6ee
File tree 2 files changed +46
-7
lines changed
app/roster/src/application/server/cmd/client
2 files changed +46
-7
lines changed Original file line number Diff line number Diff line change @@ -43,3 +43,40 @@ impl ClientID {
43
43
Ok ( ( ) )
44
44
}
45
45
}
46
+
47
+ #[ cfg( test) ]
48
+ mod tests {
49
+ use std:: io:: Cursor ;
50
+
51
+ use bytes:: BytesMut ;
52
+ use redis_async:: resp:: { RespCodec , RespValue } ;
53
+ use redis_async:: resp_array;
54
+ use tokio_util:: codec:: Encoder ;
55
+
56
+ use crate :: application:: server:: cmd:: Command ;
57
+ use crate :: application:: server:: frame:: Frame ;
58
+
59
+ fn parse_cmd ( obj : RespValue ) -> anyhow:: Result < Command > {
60
+ let mut bytes = BytesMut :: new ( ) ;
61
+ let mut codec = RespCodec ;
62
+ codec. encode ( obj, & mut bytes) . unwrap ( ) ;
63
+
64
+ let mut bytes = Cursor :: new ( bytes. freeze ( ) ) ;
65
+ let frame = Frame :: parse ( & mut bytes) ?;
66
+ let client_list = Command :: from_frame ( frame) ?;
67
+ Ok ( client_list)
68
+ }
69
+
70
+ #[ test]
71
+ fn ensure_parsing ( ) {
72
+ let entry: RespValue = resp_array ! [ "CLIENT" , "ID" ] ;
73
+ let client_cmd = parse_cmd ( entry) . unwrap ( ) ;
74
+ insta:: assert_debug_snapshot!( client_cmd, @r###"
75
+ Client(
76
+ Id(
77
+ ClientID,
78
+ ),
79
+ )
80
+ "### ) ;
81
+ }
82
+ }
Original file line number Diff line number Diff line change @@ -99,12 +99,14 @@ impl ClientList {
99
99
dst : & mut WriteConnection ,
100
100
ctx : Context ,
101
101
) -> anyhow:: Result < ( ) > {
102
+ /*
102
103
let id = ctx.connection.id();
103
104
104
105
let response = Frame::Integer(id);
105
106
dst.write_frame(&response).await?;
106
-
107
107
Ok(())
108
+ */
109
+ unimplemented ! ( )
108
110
}
109
111
}
110
112
@@ -139,7 +141,7 @@ mod tests {
139
141
Client(
140
142
List(
141
143
ClientList {
142
- type: NORMAL ,
144
+ type: Normal ,
143
145
ids: Some(
144
146
[],
145
147
),
@@ -157,7 +159,7 @@ mod tests {
157
159
Client(
158
160
List(
159
161
ClientList {
160
- type: NORMAL ,
162
+ type: Normal ,
161
163
ids: Some(
162
164
[],
163
165
),
@@ -175,7 +177,7 @@ mod tests {
175
177
Client(
176
178
List(
177
179
ClientList {
178
- type: MASTER ,
180
+ type: Master ,
179
181
ids: Some(
180
182
[],
181
183
),
@@ -193,7 +195,7 @@ mod tests {
193
195
Client(
194
196
List(
195
197
ClientList {
196
- type: REPLICA ,
198
+ type: Replica ,
197
199
ids: Some(
198
200
[],
199
201
),
@@ -211,7 +213,7 @@ mod tests {
211
213
Client(
212
214
List(
213
215
ClientList {
214
- type: PUBSUB ,
216
+ type: Pubsub ,
215
217
ids: Some(
216
218
[],
217
219
),
@@ -242,7 +244,7 @@ mod tests {
242
244
Client(
243
245
List(
244
246
ClientList {
245
- type: NORMAL ,
247
+ type: Normal ,
246
248
ids: Some(
247
249
[
248
250
1,
You can’t perform that action at this time.
0 commit comments