diff options
author | git-hulk <hulk.website@gmail.com> | 2024-01-27 22:21:54 +0800 |
---|---|---|
committer | Michael Grunder <michael.grunder@gmail.com> | 2024-01-31 12:08:52 -0800 |
commit | 5b253d89c7cc9593723334e0a45077bd4008d3db (patch) | |
tree | 5538a775daf676538f02829e3d521ab39bc5fa77 /test.c | |
parent | 2706c3e16d57c9babd24bfd83ade2efcdb13a7b8 (diff) |
Add support of RESP3 attribute type
Currently, Redis DEBUG PROTOCOL 'attrib' command will return an
attribute type, but hiredis doesn't support it yet. So it got the
protocol type error:
```
127.0.0.1:6379> DEBUG PROTOCOL attrib
Error: Protocol error, got "|" as reply type byte
```
After apply this PR, it should reply:
```
127.0.0.1:6379> DEBUG PROTOCOL attrib
1# "key-popularity"
1# 1) "key:123"
2) (integer) 90
```
Diffstat (limited to 'test.c')
-rw-r--r-- | test.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -795,6 +795,26 @@ static void test_reply_reader(void) { freeReplyObject(reply); redisReaderFree(reader); + test("Can parse RESP3 attribute: "); + reader = redisReaderCreate(); + redisReaderFeed(reader, "|2\r\n+foo\r\n:123\r\n+bar\r\n#t\r\n",26); + ret = redisReaderGetReply(reader,&reply); + test_cond(ret == REDIS_OK && + ((redisReply*)reply)->type == REDIS_REPLY_ATTR && + ((redisReply*)reply)->elements == 4 && + ((redisReply*)reply)->element[0]->type == REDIS_REPLY_STATUS && + ((redisReply*)reply)->element[0]->len == 3 && + !strcmp(((redisReply*)reply)->element[0]->str,"foo") && + ((redisReply*)reply)->element[1]->type == REDIS_REPLY_INTEGER && + ((redisReply*)reply)->element[1]->integer == 123 && + ((redisReply*)reply)->element[2]->type == REDIS_REPLY_STATUS && + ((redisReply*)reply)->element[2]->len == 3 && + !strcmp(((redisReply*)reply)->element[2]->str,"bar") && + ((redisReply*)reply)->element[3]->type == REDIS_REPLY_BOOL && + ((redisReply*)reply)->element[3]->integer); + freeReplyObject(reply); + redisReaderFree(reader); + test("Can parse RESP3 set: "); reader = redisReaderCreate(); redisReaderFeed(reader, "~5\r\n+orange\r\n$5\r\napple\r\n#f\r\n:100\r\n:999\r\n",40); |