Merge pull request #223 from martinetd/mode
irc-proto: allow empty mode
This commit is contained in:
commit
73dbbedc75
1 changed files with 29 additions and 8 deletions
|
@ -287,10 +287,8 @@ where
|
|||
})
|
||||
}
|
||||
None => {
|
||||
return Err(InvalidModeString {
|
||||
string: pieces.join(" ").to_owned(),
|
||||
cause: MissingModeModifier,
|
||||
})
|
||||
// No modifier
|
||||
return Ok(res);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -318,9 +316,32 @@ where
|
|||
|
||||
Ok(res)
|
||||
} else {
|
||||
Err(InvalidModeString {
|
||||
string: pieces.join(" ").to_owned(),
|
||||
cause: MissingModeModifier,
|
||||
})
|
||||
// No modifier
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::{ChannelMode, Mode};
|
||||
use crate::Command;
|
||||
use crate::Message;
|
||||
|
||||
#[test]
|
||||
fn parse_channel_mode() {
|
||||
let cmd = "MODE #foo +r".parse::<Message>().unwrap().command;
|
||||
assert_eq!(
|
||||
Command::ChannelMODE(
|
||||
"#foo".to_string(),
|
||||
vec![Mode::Plus(ChannelMode::RegisteredOnly, None)]
|
||||
),
|
||||
cmd
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_no_mode() {
|
||||
let cmd = "MODE #foo".parse::<Message>().unwrap().command;
|
||||
assert_eq!(Command::ChannelMODE("#foo".to_string(), vec![]), cmd);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue