add server pub/sub tests, fix pub/sub response (#27)

mini-redis server responses on PUB/SUB commands did not match real
redis.
This commit is contained in:
Carl Lerche
2020-04-06 16:34:12 -07:00
committed by GitHub
parent 922919a9d4
commit d4f0dac671
6 changed files with 205 additions and 63 deletions

View File

@@ -143,7 +143,7 @@ impl Client {
let response = self.read_response().await?;
match response {
Frame::Array(ref frame) => match frame.as_slice() {
[subscribe, schannel]
[subscribe, schannel, ..]
if subscribe.to_string() == "subscribe"
&& &schannel.to_string() == channel =>
{
@@ -235,7 +235,7 @@ impl Subscriber {
let response = self.read_response().await?;
match response {
Frame::Array(ref frame) => match frame.as_slice() {
[subscribe, schannel]
[subscribe, schannel, ..]
if &subscribe.to_string() == "subscribe"
&& &schannel.to_string() == channel =>
{
@@ -277,7 +277,7 @@ impl Subscriber {
let response = self.read_response().await?;
match response {
Frame::Array(ref frame) => match frame.as_slice() {
[unsubscribe, uchannel] if &unsubscribe.to_string() == "unsubscribe" => {
[unsubscribe, uchannel, ..] if &unsubscribe.to_string() == "unsubscribe" => {
//unsubscribed channel should exist in the subscribed list at this point
if self.subscribed_channels.remove(&uchannel.to_string()) == false {
return Err(response.to_error());